{"record":{"id":"e180d3ef2d8deac9","repo":"BigPizzaV3/CodexPlusPlus","slug":"dreamskin-e180d3","errorCode":null,"errorMessage":"DreamSkin 响应超过大小限制","messagePattern":"DreamSkin 响应超过大小限制","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":461,"sourceCode":"        .with_context(|| format!(\"请求失败：{url}\"))?;\n    if !response.status().is_success() {\n        bail!(\"DreamSkin 服务返回 HTTP {}\", response.status());\n    }\n    let content_type = response\n        .headers()\n        .get(reqwest::header::CONTENT_TYPE)\n        .and_then(|value| value.to_str().ok())\n        .and_then(|value| value.split(';').next())\n        .map(str::trim)\n        .unwrap_or_default();\n    if content_type != expected_content_type {\n        bail!(\"DreamSkin 服务返回了不支持的内容类型：{content_type}\");\n    }\n    if response\n        .content_length()\n        .is_some_and(|length| length == 0 || length > limit as u64)\n    {\n        bail!(\"DreamSkin 响应超过大小限制\");\n    }\n    let mut bytes = Vec::new();\n    let mut stream = response.bytes_stream();\n    while let Some(chunk) = stream.next().await {\n        let chunk = chunk?;\n        if bytes.len().saturating_add(chunk.len()) > limit {\n            bail!(\"DreamSkin 响应超过大小限制\");\n        }\n        bytes.extend_from_slice(&chunk);\n    }\n    if bytes.is_empty() {\n        bail!(\"DreamSkin 服务返回空响应\");\n    }\n    Ok(bytes)\n}\n\n#[cfg(test)]\nmod tests {","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L443-L479","documentation":"download_limited enforces a size limit on the streamed response body: it first checks the Content-Length header, then accumulates chunks and bails as soon as the total would exceed the caller-provided limit. This protects against oversized or unbounded responses (memory exhaustion) from the DreamSkin service.","triggerScenarios":"fetch_community_catalog or install_community_theme receiving a body whose declared Content-Length is 0 or exceeds the limit, or whose streamed chunks accumulate past the limit (declared length may be absent/lying).","commonSituations":"Server misconfiguration returning an uncompressed or concatenated payload; a compromised/misbehaving mirror streaming endless data; downloading a package that legitimately grew beyond the 32 MiB cap; proxy injecting extra content.","solutions":["Check the actual response size; if the package legitimately exceeds the limit, it must be republished under 32 MiB.","Enable compression checks/server-side minification and re-download; verify with curl -I that Content-Length is sane.","Retry — if a proxy is inflating responses, bypass it or fix its configuration.","Report an unbounded-streaming endpoint to the service operator as a potential abuse vector."],"exampleFix":"// before\nlet bytes = download_limited(&client, &pkg_url, \"application/zip\", UNTRUSTED_HUGE_LIMIT).await?;\n// after\nlet bytes = download_limited(&client, &pkg_url, \"application/zip\", PACKAGE_BYTES_LIMIT).await?; // republish the package if it truly exceeds this","handlingStrategy":"validation","validationCode":"// Rust\nlet resp = client.head(&url).send().await?;\nlet too_big = resp.content_length().is_some_and(|n| n == 0 || n > PACKAGE_BYTES_LIMIT);","typeGuard":null,"tryCatchPattern":"// Rust\nErr(e) if e.to_string().contains(\"大小限制\") => {\n    eprintln!(\"响应超过 32 MiB 限制：请确认主题包未被替换或服务未被滥用\");\n}","preventionTips":["Keep published packages under the documented size cap","Use HEAD requests to pre-check Content-Length before streaming","Never raise the limit client-side to 'fix' this error — verify the source first","Report endpoints that stream without a sane Content-Length"],"tags":["network","http","size-limit","security"],"backgroundTag":"file-size-limit-exceeded","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"}