{"record":{"id":"c5c6779ce97fbd14","repo":"iflytek/astron-agent","slug":"audio-file-format-unsupported","errorCode":"AUDIO_FILE_FORMAT_UNSUPPORTED","errorMessage":"AUDIO_FILE_FORMAT_UNSUPPORTED","messagePattern":"AUDIO_FILE_FORMAT_UNSUPPORTED","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java","lineNumber":72,"sourceCode":"        // 2. Check file size\n        validateFileSize(file);\n\n        // 3. Check audio properties\n        validateAudioProperties(file);\n    }\n\n    /**\n     * Validate file format\n     */\n    private static void validateFileFormat(MultipartFile file) throws BusinessException {\n        String filename = file.getOriginalFilename();\n        if (filename == null) {\n            throw new BusinessException(ResponseEnum.PARAM_MISS);\n        }\n\n        String extension = getFileExtension(filename).toLowerCase();\n        if (!SUPPORTED_FORMATS.contains(extension)) {\n            throw new BusinessException(ResponseEnum.AUDIO_FILE_FORMAT_UNSUPPORTED);\n        }\n    }\n\n    /**\n     * Validate file size\n     */\n    private static void validateFileSize(MultipartFile file) throws BusinessException {\n        if (file.getSize() > MAX_FILE_SIZE_BYTES) {\n            throw new BusinessException(ResponseEnum.AUDIO_FILE_SIZE_EXCEEDED);\n        }\n    }\n\n    /**\n     * Validate audio properties\n     */\n    private static void validateAudioProperties(MultipartFile file) throws BusinessException {\n        String filename = file.getOriginalFilename();\n        if (filename == null) {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java#L54-L90","documentation":"BusinessException(ResponseEnum.AUDIO_FILE_FORMAT_UNSUPPORTED) thrown by AudioValidator.validateFileFormat when the file extension (lowercased) is not in SUPPORTED_FORMATS. The validator whitelists audio container formats before doing deeper audio-property validation, so anything outside the whitelist is rejected immediately.","triggerScenarios":"Uploading audio whose extension is not in the supported set — e.g. .ogg, .flac, .aac, .webm, or a file with no/misnamed extension — into the audio upload endpoint validated by validateAudioFile.","commonSituations":"Users uploading recordings saved by apps that default to ogg/webm; files renamed without converting (renaming .mp3 to .wav does not convert); extensionless downloads; uppercase or double extensions (.WAV.bak) that fail the whitelist.","solutions":["Convert the audio to a supported format (wav/mp3/m4a per SUPPORTED_FORMATS) with ffmpeg: ffmpeg -i input.ogg output.wav.","Ensure the file has the correct, matching extension for its actual format.","Check SUPPORTED_FORMATS in AudioValidator to confirm which extensions are accepted for this endpoint.","Do not simply rename the extension — re-encode the file so container and extension agree."],"exampleFix":"// before: rejected upload\nupload(file=\"voice_note.ogg\")\n// after: convert to supported format first\n// ffmpeg -i voice_note.ogg voice_note.wav\nupload(file=\"voice_note.wav\")","handlingStrategy":"validation","validationCode":"const ok = ['wav','mp3','m4a'].includes(file.name.split('.').pop().toLowerCase());\nif (!ok) { alert('Unsupported format; convert to wav/mp3/m4a'); return; }","typeGuard":"boolean isSupportedAudio(String filename) { String ext = extensionOf(filename); return ext != null && SUPPORTED_FORMATS.contains(ext.toLowerCase()); }","tryCatchPattern":"try { AudioValidator.validateAudioFile(file); }\ncatch (BusinessException e) { if (ResponseEnum.AUDIO_FILE_FORMAT_UNSUPPORTED.equals(e.getResponseEnum())) { /* 415: tell user to convert format */ } else { throw e; } }","preventionTips":["Filter by accepted extensions in the file picker (accept=\".wav,.mp3,.m4a\").","Show the supported-format list to users before upload.","Re-encode with ffmpeg rather than renaming extensions.","Keep server SUPPORTED_FORMATS list documented and mirrored client-side."],"tags":["java","audio","validation","unsupported-format"],"backgroundTag":"unsupported-enum-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}