{"record":{"id":"7fd5de15a80dbc3e","repo":"langgenius/dify","slug":"unsupported-audio-type-7fd5de","errorCode":"unsupported_audio_type","errorMessage":"Audio type not allowed.","messagePattern":"Audio type not allowed\\.","errorType":"error_code","errorClass":"UnsupportedAudioTypeError","httpStatus":415,"severity":"warning","filePath":"api/controllers/console/explore/trial.py","lineNumber":688,"sourceCode":"            user_id = current_user.id\n\n            response = AudioService.transcript_asr(\n                app_model=app_model,\n                file=file,\n                session=db.session(),\n                end_user=None,\n            )\n            RecommendedAppService.add_trial_app_record(app_id, user_id, session=db.session())\n            return response\n        except services.errors.app_model_config.AppModelConfigBrokenError:\n            logger.exception(\"App model config broken.\")\n            raise AppUnavailableError()\n        except NoAudioUploadedServiceError:\n            raise NoAudioUploadedError()\n        except AudioTooLargeServiceError as e:\n            raise AudioTooLargeError(str(e))\n        except UnsupportedAudioTypeServiceError:\n            raise UnsupportedAudioTypeError()\n        except ProviderNotSupportSpeechToTextServiceError:\n            raise ProviderNotSupportSpeechToTextError()\n        except SpeechToTextDisabledServiceError:\n            raise SpeechToTextDisabledError()\n        except ProviderTokenNotInitError as ex:\n            raise ProviderNotInitializeError(ex.description)\n        except QuotaExceededError:\n            raise ProviderQuotaExceededError()\n        except ModelCurrentlyNotSupportError:\n            raise ProviderModelCurrentlyNotSupportError()\n        except InvokeError as e:\n            raise CompletionRequestError(e.description)\n        except ValueError as e:\n            raise e\n        except Exception as e:\n            logger.exception(\"internal server error.\")\n            raise InternalServerError()\n","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/explore/trial.py#L670-L706","documentation":"HTTP 415 with error_code `unsupported_audio_type`, raised by UnsupportedAudioTypeError when AudioService raises UnsupportedAudioTypeServiceError. The uploaded file's MIME/extension is not in the allowlist of accepted audio formats. The check happens after the upload is received but before transcription.","triggerScenarios":"POST TrialChatAudioApi with a file whose content type or extension is not a supported audio type (e.g. video/mp4, audio of an uncommon codec, or a non-audio file renamed to .mp3).","commonSituations":"Client recorded in a container format the server rejects (e.g. .ogg with video); user attached a text/image file by mistake; browser reported a generic application/octet-stream MIME that the server cannot map.","solutions":["Convert the upload to a supported format (typically mp3 or wav) before sending.","Set the correct Content-Type / filename extension so the server's type detection passes.","If you operate the server and need a new format, extend the allowlist in AudioService rather than renaming files."],"exampleFix":"// before - sending an unsupported container\nfd.append('file', webmBlob, 'audio.mkv')\n\n// after - transcode to mp3 with a proper extension\nconst mp3 = await transcodeToMp3(webmBlob)\nfd.append('file', mp3, 'audio.mp3')","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/webm', 'audio/x-m4a'])\nif (!SUPPORTED.has(file.type)) {\n  file = await transcodeToMp3(file)\n}","typeGuard":"const SUPPORTED_AUDIO = new Set(['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/webm', 'audio/x-m4a'])\nfunction isSupportedAudio(file: File): boolean {\n  return SUPPORTED_AUDIO.has(file.type)\n}","tryCatchPattern":"try {\n  const r = await fetch(audioUrl, { method: 'POST', body: fd })\n  if (r.status === 415) promptConvertFormat()\n} catch (e) { reportToUser(e) }","preventionTips":["Send audio in a widely supported format (mp3 or wav).","Set the correct MIME/extension; do not rely on the server guessing.","Reject non-audio files in the file picker before upload."],"tags":["dify","trial-api","console","explore","audio","upload","mime-type","http-415","validation"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}