openai/codex · error · std::io::Error

code-mode IPC frame declares

Error message

code-mode IPC frame declares {length} payload bytes but contains {}

What it means

Returned by the code-mode IPC frame decoder when the u32 length prefix declares more payload bytes than actually remain in the received buffer, indicating a truncated or corrupt frame. This is a protocol-framing invariant violation on the stdin IPC channel, not a size-limit breach (that is the MAX_FRAME_BYTES error).

Solutions

  1. Check for a truncated or interleaved stream (partial writes, concurrency bug)
  2. Verify sender and receiver agree on the length-prefix framing
  3. Re-establish the connection
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/code-mode-protocol/src/host/codec.rs:75 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/ed24e64566d63fa5. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/code-mode-protocol/src/host/codec.rs:75

            .get(..size_of::<u32>())
            .and_then(|length_bytes| length_bytes.try_into().ok())
            .ok_or_else(|| {
                io::Error::new(
                    io::ErrorKind::InvalidData,
                    "code-mode IPC frame is missing its length prefix",
                )
            })?;
        let length = u32::from_le_bytes(length_bytes) as usize;
        if length > MAX_FRAME_BYTES {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                format!("code-mode IPC frame length {length} exceeds {MAX_FRAME_BYTES} bytes"),
            ));
        }

        let payload = &bytes[size_of::<u32>()..];
        if payload.len() != length {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                format!(
                    "code-mode IPC frame declares {length} payload bytes but contains {}",
                    payload.len()
                ),
            ));
        }

        serde_json::from_slice(payload).map_err(|err| {
            io::Error::new(
                io::ErrorKind::InvalidData,
                format!("failed to decode code-mode IPC frame: {err}"),
            )
        })
    }
}

/// Decodes JSON messages prefixed by a four-byte little-endian payload length.

View on GitHub (pinned to 339751715c)