{"record":{"id":"bdb05b6457b36729","repo":"danny-avila/LibreChat","slug":"the-audio-file-format-rawformat-is-not-accepted","errorCode":null,"errorMessage":"The audio file format ${rawFormat} is not accepted","messagePattern":"The audio file format (.+?) is not accepted","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"api/server/services/Files/Audio/STTService.js","lineNumber":255,"sourceCode":"      azureOpenAIApiDeploymentName: extractEnvVariable(sttSchema?.deploymentName),\n    })}/audio/transcriptions?api-version=${extractEnvVariable(sttSchema?.apiVersion)}`;\n\n    const apiKey = sttSchema.apiKey ? resolveConfigSecret(sttSchema.apiKey) || '' : '';\n\n    if (audioBuffer.byteLength > 25 * 1024 * 1024) {\n      throw new Error('The audio file size exceeds the limit of 25MB');\n    }\n\n    const acceptedFormats = ['flac', 'mp3', 'mp4', 'mpeg', 'mpga', 'm4a', 'ogg', 'wav', 'webm'];\n    const [mimePrefix, rawFormat = ''] = audioFile.mimetype.split('/');\n    const isAudioMime = mimePrefix === 'audio' || mimePrefix === 'video';\n    const isKnownMime = audioFile.mimetype in MIME_TO_EXTENSION_MAP;\n    const normalizedFormat = isKnownMime ? MIME_TO_EXTENSION_MAP[audioFile.mimetype] : null;\n    if (\n      !acceptedFormats.includes(normalizedFormat) &&\n      !(isAudioMime && acceptedFormats.includes(rawFormat))\n    ) {\n      throw new Error(`The audio file format ${rawFormat} is not accepted`);\n    }\n\n    const formData = new FormData();\n    formData.append('file', audioBuffer, {\n      filename: audioFile.originalname,\n      contentType: audioFile.mimetype,\n    });\n\n    const validLanguage = getValidatedLanguageCode(language);\n    if (validLanguage) {\n      formData.append('language', validLanguage);\n    }\n\n    const headers = {\n      ...(apiKey && { 'api-key': apiKey }),\n    };\n\n    [headers].forEach(this.removeUndefined);","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/Audio/STTService.js#L237-L273","documentation":"azureOpenAIProvider accepts only flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. It first normalizes the upload's MIME through MIME_TO_EXTENSION_MAP; if not mapped, it falls back to the subtype after the `/`. If neither result is in acceptedFormats, it throws with the offending subtype.","triggerScenarios":"Upload audio whose normalized extension and raw subtype are both outside the allowlist — e.g. audio/aac, audio/x-aiff, audio/ac3, video/quicktime.","commonSituations":"Browser reports an uncommon MIME; recorder produces AAC/AIFF; multer/file-type detection mislabels the file; user uploads a container the provider doesn't support.","solutions":["Transcode the file to an accepted format (mp3, wav, ogg, or webm) before upload.","Ensure the upload's Content-Type/mimetype is correct for the actual bytes.","Only if a mapped format is genuinely supported by your deployment, extend MIME_TO_EXTENSION_MAP to normalize it into an accepted extension."],"exampleFix":"// before: send audio/aac directly\n// after: transcode to mp3 before upload (ffmpeg)\n// ffmpeg -i input.aac -codec:a libmp3lame output.mp3","handlingStrategy":"validation","validationCode":"const ACCEPTED = ['flac','mp3','mp4','mpeg','mpga','m4a','ogg','wav','webm'];\nconst [, raw = ''] = audioFile.mimetype.split('/');\nif (!ACCEPTED.includes(rawFormat)) {\n  return res.status(415).json({ error: `Unsupported audio format: ${rawFormat}` });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Transcode uploads to an accepted format before sending.","Validate the MIME subtype against the accepted list at the route boundary.","Use a content-sniffing library (e.g. file-type) to trust bytes over client-declared MIME."],"tags":["stt","azure-openai","mime","input-validation"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}