{"record":{"id":"c25154e262889dcb","repo":"openai/codex","slug":"kind-input-exceeds-max-bytes-bytes","errorCode":null,"errorMessage":"{kind} input exceeds {max_bytes} bytes","messagePattern":"(.+?) input exceeds (.+?) bytes","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/protocol/src/local_media.rs","lineNumber":57,"sourceCode":"            })?;\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 {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"{kind} input exceeds {max_bytes} bytes\"),\n        ));\n    }\n\n    let mut bytes = Vec::new();\n    file.take(max_bytes as u64 + 1).read_to_end(&mut bytes)?;\n    if bytes.len() > max_bytes {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"{kind} input exceeds {max_bytes} bytes\"),\n        ));\n    }\n    Ok(bytes)\n}\n\npub(crate) fn audio_mime_for_path(path: &Path) -> Option<&'static str> {\n    let extension = path.extension()?.to_str()?;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/protocol/src/local_media.rs#L39-L75","documentation":"io::Error(ErrorKind::InvalidData, '{kind} input exceeds {max_bytes} bytes') raised by read_bounded_local_media (codex-rs/protocol/src/local_media.rs:56-61) during the pre-read metadata check: file.metadata().len() is compared to the cap before any bytes are read. kind is 'image' with the image byte cap from codex_utils_image (MAX_PROMPT_IMAGE_INPUT_BYTES) or 'audio' with MAX_PROMPT_AUDIO_INPUT_BYTES = 50 MiB (local_media.rs:16). Oversized local media is refused so it is never read into memory or uploaded.","triggerScenarios":"snapshot_local_user_input on a UserInput::LocalImage larger than the image byte cap, or a UserInput::LocalAudio larger than 50 MiB; the message states which kind and the exact byte limit.","commonSituations":"Huge screenshots or uncompressed TIFF/RAW photos as images; hour-long uncompressed WAV recordings (50 MiB is roughly 50 minutes of WAV); pipeline artifacts that were never compressed.","solutions":["Shrink the file below the printed cap: compress or resize images (avoid forcing ImageDetail::Original so Codex can resize), transcode audio to MP3/OGG or trim it.","Pre-check size before queueing: compare fs::metadata(path).len() against the same limits.","For long audio, use compressed containers - they fit far more duration per byte than WAV.","If all the content matters, split it into several smaller inputs."],"exampleFix":"// before: queueing a giant WAV\nUserInput::LocalAudio { path: Path::new(\"/tmp/3h.wav\").into() }\n// > MAX_PROMPT_AUDIO_INPUT_BYTES (50 MiB) -> InvalidData\n\n// after: transcode/trim under the cap first\n// ffmpeg -i 3h.wav -t 1800 -b:a 64k excerpt.mp3\nUserInput::LocalAudio { path: Path::new(\"/tmp/excerpt.mp3\").into() }","handlingStrategy":"validation","validationCode":"fn within_cap(path: &Path, max_bytes: usize) -> bool {\n    std::fs::metadata(path)\n        .map(|m| m.len() <= max_bytes as u64)\n        .unwrap_or(false)\n}\n// images: max_bytes = codex_utils_image::MAX_PROMPT_IMAGE_INPUT_BYTES\n// audio:  max_bytes = MAX_PROMPT_AUDIO_INPUT_BYTES (50 MiB)","typeGuard":"fn is_size_exceeded(err: &io::Error) -> bool {\n    err.kind() == io::ErrorKind::InvalidData && err.to_string().contains(\"input exceeds\")\n}","tryCatchPattern":"Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"input exceeds\") => {\n    // surface the cap from the message; ask the user to compress or trim\n}","preventionTips":["Size-check files before adding them to the input queue.","Default to compressed audio formats.","Avoid ImageDetail::Original for large images so the resize path can shrink them."],"tags":["rust","codex","file-size","limit","image","audio","user-input"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}