langgenius/dify · warning · UnsupportedAudioTypeError

unsupported_audio_type

unsupported_audio_type

Error message

Audio type not allowed.

What it means

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.

Source

Thrown at api/controllers/console/explore/trial.py:688

            user_id = current_user.id

            response = AudioService.transcript_asr(
                app_model=app_model,
                file=file,
                session=db.session(),
                end_user=None,
            )
            RecommendedAppService.add_trial_app_record(app_id, user_id, session=db.session())
            return response
        except services.errors.app_model_config.AppModelConfigBrokenError:
            logger.exception("App model config broken.")
            raise AppUnavailableError()
        except NoAudioUploadedServiceError:
            raise NoAudioUploadedError()
        except AudioTooLargeServiceError as e:
            raise AudioTooLargeError(str(e))
        except UnsupportedAudioTypeServiceError:
            raise UnsupportedAudioTypeError()
        except ProviderNotSupportSpeechToTextServiceError:
            raise ProviderNotSupportSpeechToTextError()
        except SpeechToTextDisabledServiceError:
            raise SpeechToTextDisabledError()
        except ProviderTokenNotInitError as ex:
            raise ProviderNotInitializeError(ex.description)
        except QuotaExceededError:
            raise ProviderQuotaExceededError()
        except ModelCurrentlyNotSupportError:
            raise ProviderModelCurrentlyNotSupportError()
        except InvokeError as e:
            raise CompletionRequestError(e.description)
        except ValueError as e:
            raise e
        except Exception as e:
            logger.exception("internal server error.")
            raise InternalServerError()

View on GitHub (pinned to ef8544b173)

Solutions

  1. Convert the upload to a supported format (typically mp3 or wav) before sending.
  2. Set the correct Content-Type / filename extension so the server's type detection passes.
  3. If you operate the server and need a new format, extend the allowlist in AudioService rather than renaming files.

Example fix

// before - sending an unsupported container
fd.append('file', webmBlob, 'audio.mkv')

// after - transcode to mp3 with a proper extension
const mp3 = await transcodeToMp3(webmBlob)
fd.append('file', mp3, 'audio.mp3')
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/webm', 'audio/x-m4a'])
if (!SUPPORTED.has(file.type)) {
  file = await transcodeToMp3(file)
}

Type guard

const SUPPORTED_AUDIO = new Set(['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/webm', 'audio/x-m4a'])
function isSupportedAudio(file: File): boolean {
  return SUPPORTED_AUDIO.has(file.type)
}

Try / catch

try {
  const r = await fetch(audioUrl, { method: 'POST', body: fd })
  if (r.status === 415) promptConvertFormat()
} catch (e) { reportToUser(e) }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/7fd5de15a80dbc3e. Report an issue: GitHub.