{"record":{"id":"5d2219a9b7bf6a7d","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-5d2219","errorCode":null,"errorMessage":"解压后的请求体超过大小限制","messagePattern":"解压后的请求体超过大小限制","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/codex-plus-core/src/launcher.rs","lineNumber":1445,"sourceCode":"    }\n    stream.shutdown().await?;\n    Ok(())\n}\n\nfn decode_protocol_proxy_request_body(\n    body: &[u8],\n    content_encoding: Option<&str>,\n) -> anyhow::Result<String> {\n    let encoding = content_encoding.unwrap_or_default().trim();\n    let decoded = if encoding.is_empty() || encoding.eq_ignore_ascii_case(\"identity\") {\n        body.to_vec()\n    } else if encoding.eq_ignore_ascii_case(\"zstd\") {\n        let decoder = zstd::stream::read::Decoder::new(std::io::Cursor::new(body))?;\n        let mut limited = decoder.take((MAX_HTTP_BODY_BYTES + 1) as u64);\n        let mut decoded = Vec::new();\n        limited.read_to_end(&mut decoded)?;\n        if decoded.len() > MAX_HTTP_BODY_BYTES {\n            anyhow::bail!(\"解压后的请求体超过大小限制\");\n        }\n        decoded\n    } else {\n        anyhow::bail!(\"不支持的 Content-Encoding：{encoding}\");\n    };\n\n    String::from_utf8(decoded)\n        .map_err(|error| anyhow::anyhow!(\"Responses 请求体不是 UTF-8：{error}\"))\n}\n\nfn overlay_image_response() -> (String, Vec<u8>, String, &'static str) {\n    let not_found = || {\n        (\n            \"404 Not Found\".to_string(),\n            serde_json::to_vec(&serde_json::json!({\n                \"status\": \"failed\",\n                \"message\": \"图片覆盖层未启用或图片不可用\"\n            }))","sourceCodeStart":1427,"sourceCodeEnd":1463,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/launcher.rs#L1427-L1463","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Reduce the request payload size so the decompressed body fits under MAX_HTTP_BODY_BYTES","Disable compression (omit Content-Encoding) and send the body uncompressed if it is near the limit","Raise MAX_HTTP_BODY_BYTES in the launcher configuration/code if larger bodies are legitimately required"],"exampleFix":"// before\nlet mut limited = decoder.take((MAX_HTTP_BODY_BYTES + 1) as u64);\n// after\nlet mut limited = decoder.take((MAX_HTTP_BODY_BYTES * 4) as u64); // if the cap was raised intentionally","handlingStrategy":"validation","validationCode":"// before sending, cap the payload\nconst MAX: usize = MAX_HTTP_BODY_BYTES;\nif uncompressed_body.len() > MAX { throw new Error(`body exceeds ${MAX} bytes`); }","typeGuard":null,"tryCatchPattern":"match decode_request_body(body, encoding) {\n    Ok(decoded) => handle(decoded),\n    Err(e) if e.to_string().contains(\"大小限制\") => respond(413, \"payload too large\"),\n    Err(e) => respond(400, format!(\"bad request: {e}\")),\n}","preventionTips":["Check payload size before compressing/sending","Document the MAX_HTTP_BODY_BYTES limit in client SDKs","Avoid compressing bodies already near the limit","Monitor response for 413-style messages"],"tags":["rust","http","zstd","decompression","payload-size"],"backgroundTag":"payload-too-large","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}