BigPizzaV3/CodexPlusPlus · warning · anyhow::Error

解压后的请求体超过大小限制

Error message

解压后的请求体超过大小限制

What it means

When decoding an HTTP request body with `Content-Encoding: zstd`, the launcher decompresses with a limit of MAX_HTTP_BODY_BYTES+1 and then rejects the result if it exceeds MAX_HTTP_BODY_BYTES. This prevents decompression-bomb payloads from exhausting memory, enforcing a hard cap on the decoded size.

Solutions

  1. Reduce the request payload size so the decompressed body fits under MAX_HTTP_BODY_BYTES
  2. Disable compression (omit Content-Encoding) and send the body uncompressed if it is near the limit
  3. Raise MAX_HTTP_BODY_BYTES in the launcher configuration/code if larger bodies are legitimately required

Example fix

// before
let mut limited = decoder.take((MAX_HTTP_BODY_BYTES + 1) as u64);
// after
let mut limited = decoder.take((MAX_HTTP_BODY_BYTES * 4) as u64); // if the cap was raised intentionally
Defensive patterns

Strategy: validation

Validate before calling

// before sending, cap the payload
const MAX: usize = MAX_HTTP_BODY_BYTES;
if uncompressed_body.len() > MAX { throw new Error(`body exceeds ${MAX} bytes`); }

Try / catch

match decode_request_body(body, encoding) {
    Ok(decoded) => handle(decoded),
    Err(e) if e.to_string().contains("大小限制") => respond(413, "payload too large"),
    Err(e) => respond(400, format!("bad request: {e}")),
}

Prevention

When it happens

Trigger: A client sends a Responses API request with `Content-Encoding: zstd` whose decompressed body is larger than MAX_HTTP_BODY_BYTES (the take() reads one extra byte specifically to detect this).

Common situations: Large request payloads (huge context or file uploads) compressed with zstd; misconfigured proxies re-compressing large bodies; clients not respecting a documented body-size limit.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/5d2219a9b7bf6a7d. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/launcher.rs:1445

    }
    stream.shutdown().await?;
    Ok(())
}

fn decode_protocol_proxy_request_body(
    body: &[u8],
    content_encoding: Option<&str>,
) -> anyhow::Result<String> {
    let encoding = content_encoding.unwrap_or_default().trim();
    let decoded = if encoding.is_empty() || encoding.eq_ignore_ascii_case("identity") {
        body.to_vec()
    } else if encoding.eq_ignore_ascii_case("zstd") {
        let decoder = zstd::stream::read::Decoder::new(std::io::Cursor::new(body))?;
        let mut limited = decoder.take((MAX_HTTP_BODY_BYTES + 1) as u64);
        let mut decoded = Vec::new();
        limited.read_to_end(&mut decoded)?;
        if decoded.len() > MAX_HTTP_BODY_BYTES {
            anyhow::bail!("解压后的请求体超过大小限制");
        }
        decoded
    } else {
        anyhow::bail!("不支持的 Content-Encoding:{encoding}");
    };

    String::from_utf8(decoded)
        .map_err(|error| anyhow::anyhow!("Responses 请求体不是 UTF-8:{error}"))
}

fn overlay_image_response() -> (String, Vec<u8>, String, &'static str) {
    let not_found = || {
        (
            "404 Not Found".to_string(),
            serde_json::to_vec(&serde_json::json!({
                "status": "failed",
                "message": "图片覆盖层未启用或图片不可用"
            }))

View on GitHub (pinned to b1ed92e5e4)