dify icon indicating copy to clipboard operation
dify copied to clipboard

In-app API docs for /audio-to-text drift from implementation: format list, size limit, unreachable error codes

Open RiskeyL opened this issue 4 months ago • 3 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

main (dc8dd09450); also present in 1.16.1 and earlier

Cloud or Self Hosted

Cloud and Self Hosted (the drift is in the shipped code, so it affects every deployment)

Steps to reproduce

  1. Open any Chat/Chatflow app → API Access → the Audio to text section (rendered from web/app/components/develop/template/template_chat.*.mdx / template_advanced_chat.*.mdx, en/ja/zh).
  2. Compare with the implementation:
    • api/constants/__init__.py L12: _AUDIO_EXTENSION_BASE = ("mp3", "m4a", "wav", "amr", "mpga")
    • api/services/audio_service.py L31–32: FILE_SIZE = 30 (MB)
  3. Read the /audio-to-text OpenAPI docstring in api/controllers/service_api/app/audio.py (both @service_api_ns.doc response blocks, ~L58 and ~L158) and trace the listed 400 codes to their raise sites.

✔️ Expected Behavior

The in-app API docs describe what the endpoint accepts and returns:

  • Supported formats: mp3, m4a, wav, amr, mpga; file size limit 30 MB.
  • The 400 error list contains only codes reachable via this endpoint.

❌ Actual Behavior

Three documentation surfaces disagree with the implementation:

  1. Format list — the in-app templates say ['mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'wav', 'webm']. mp4, mpeg and webm are rejected with unsupported_audio_type (415); amr is accepted but undocumented.
  2. Size limit — the templates say 15MB; the service accepts up to 30 MB, so valid 15–30 MB uploads look forbidden to readers.
  3. Unreachable error codes — the controller docstring advertises app_unavailable, provider_quota_exceeded and model_currently_not_support for 400 responses, but no code path reachable from /audio-to-text raises the mapped exceptions: AppModelConfigBrokenError is raised only in message_based_app_generator, and QuotaExceededError / ModelCurrentlyNotSupportError only in the easy-UI model-config converter and llm/quota. AudioService._invoke_speech_to_text raises none of them. (The reference docs at docs.dify.ai were corrected in langgenius/dify-docs#903; this issue is for the two in-repo surfaces.)

Affected files: web/app/components/develop/template/template_chat.{en,ja,zh}.mdx, template_advanced_chat.{en,ja,zh}.mdx, api/controllers/service_api/app/audio.py.

RiskeyL avatar Aug 03 '26 06:08 RiskeyL

I'll take this. On current main the in-app MDX templates are gone and the /audio-to-text format list plus 30 MB limit already match the implementation. The remaining drift is the 400 list advertising unreachable codes. I'll send a docs PR that keeps only reachable errors.

Theater-ahyeon avatar Sep 02 '26 18:09 Theater-ahyeon

Hi @maintainers, I would like to work on this issue. Please assign it to me.

hardiekk avatar Sep 06 '26 21:09 hardiekk

I'd like to take this one. I verified the defect is still present on current main, checked that no open PR covers it, and prepared a minimal patch with an offline check. Opening a focused PR from my fork now.

severus0044 avatar Nov 08 '26 08:11 severus0044