{"record":{"id":"0e1228e89d6e6cee","repo":"openai/codex","slug":"unsupported-audio-format","errorCode":null,"errorMessage":"unsupported audio format","messagePattern":"unsupported audio format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/protocol/src/local_media.rs","lineNumber":38,"sourceCode":"    match input {\n        UserInput::LocalImage { path, detail } => {\n            let image_detail = *detail;\n            let mode = match image_detail {\n                Some(ImageDetail::Original) => PromptImageMode::Original,\n                Some(ImageDetail::Auto | ImageDetail::Low | ImageDetail::High) | None => {\n                    PromptImageMode::ResizeToFit\n                }\n            };\n            let file_bytes = read_bounded_local_media(path, MAX_PROMPT_IMAGE_INPUT_BYTES, \"image\")?;\n            let image = load_for_prompt_bytes(path, file_bytes, mode).map_err(io::Error::other)?;\n            *input = UserInput::Image {\n                image_url: image.into_data_url(),\n                detail: image_detail,\n            };\n        }\n        UserInput::LocalAudio { path } => {\n            let mime = audio_mime_for_path(path).ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidData, \"unsupported audio format\")\n            })?;\n            let file_bytes = read_bounded_local_media(path, MAX_PROMPT_AUDIO_INPUT_BYTES, \"audio\")?;\n            *input = UserInput::Audio {\n                audio_url: data_url_from_bytes(mime, &file_bytes),\n            };\n        }\n        UserInput::Text { .. }\n        | UserInput::Image { .. }\n        | UserInput::Audio { .. }\n        | UserInput::Skill { .. }\n        | UserInput::Mention { .. } => {}\n    }\n    Ok(())\n}\n\nfn read_bounded_local_media(path: &Path, max_bytes: usize, kind: &str) -> io::Result<Vec<u8>> {\n    let file = std::fs::File::open(path)?;\n    if file.metadata()?.len() > max_bytes as u64 {","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/protocol/src/local_media.rs#L20-L56","documentation":"io::Error(ErrorKind::InvalidData, 'unsupported audio format') from snapshot_local_user_input (codex-rs/protocol/src/local_media.rs:37-39): a UserInput::LocalAudio path failed audio_mime_for_path (local_media.rs:74-89), which maps only .wav, .mp3, .m4a, .webm, and .ogg (case-insensitive) to MIME types. Detection is purely extension-based - content is never sniffed - and files with any other or missing extension are rejected before being read.","triggerScenarios":"Queueing UserInput::LocalAudio { path } (via prepare_queued_user_input / snapshot_local_user_input) whose extension is outside wav/mp3/m4a/webm/ogg - for example .flac, .aac, .opus, .txt, or no extension at all.","commonSituations":"Users attach FLAC or AAC recordings; downloads arrive with unusual extensions; files saved without extensions; double extensions like .mp3.txt.","solutions":["Convert the audio to a supported container (WAV, MP3, M4A, WebM, or OGG), e.g. ffmpeg -i in.flac out.mp3.","If the content is already a supported format but misnamed, rename it so the extension matches the actual container.","Verify the final extension before queueing - matching is extension-only, so the name must agree with the bytes."],"exampleFix":"// before: attaching an unsupported file\nUserInput::LocalAudio { path: Path::new(\"/tmp/interview.flac\").into() }\n// snapshot_local_user_input -> InvalidData: unsupported audio format\n\n// after: convert to a supported format first\n// ffmpeg -i interview.flac interview.mp3\nUserInput::LocalAudio { path: Path::new(\"/tmp/interview.mp3\").into() }","handlingStrategy":"validation","validationCode":"const SUPPORTED: &[&str] = &[\"wav\", \"mp3\", \"m4a\", \"webm\", \"ogg\"];\nfn audio_supported(path: &Path) -> bool {\n    path.extension()\n        .and_then(|e| e.to_str())\n        .is_some_and(|e| SUPPORTED.iter().any(|s| e.eq_ignore_ascii_case(s)))\n}\n// gate before snapshotting:\nif !audio_supported(&path) {\n    reject_with_hint(&path);\n}","typeGuard":"fn is_unsupported_audio(err: &io::Error) -> bool {\n    err.kind() == io::ErrorKind::InvalidData\n        && err.to_string().contains(\"unsupported audio format\")\n}","tryCatchPattern":"match snapshot_local_user_input(&mut input) {\n    Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"unsupported audio format\") => {\n        // tell the user which formats are accepted (wav/mp3/m4a/webm/ogg)\n    }\n    other => other?,\n}","preventionTips":["Filter file pickers to supported audio extensions.","Convert uploads with ffmpeg before queueing them.","Remember detection is extension-only: name files to match their true container."],"tags":["rust","codex","audio","mime-type","validation","user-input"],"backgroundTag":"unsupported-media-format","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}