{"record":{"id":"98919524a3b9c0eb","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-989195","errorCode":null,"errorMessage":"下载内容为空","messagePattern":"下载内容为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_market.rs","lineNumber":279,"sourceCode":"        .error_for_status()\n        .with_context(|| format!(\"服务器返回错误状态：{url}\"))?;\n    if response\n        .content_length()\n        .is_some_and(|size| size > limit as u64)\n    {\n        bail!(\"下载内容超过 {} 字节限制\", limit);\n    }\n    let mut stream = response.bytes_stream();\n    let mut bytes = Vec::new();\n    while let Some(chunk) = stream.next().await {\n        let chunk = chunk.context(\"读取下载内容失败\")?;\n        if bytes.len().saturating_add(chunk.len()) > limit {\n            bail!(\"下载内容超过 {} 字节限制\", limit);\n        }\n        bytes.extend_from_slice(&chunk);\n    }\n    if bytes.is_empty() {\n        bail!(\"下载内容为空\");\n    }\n    Ok(bytes)\n}\n\nfn cache_manifest(state_dir: &Path, manifest: &DreamSkinMarketManifest) -> anyhow::Result<()> {\n    let bytes = serde_json::to_vec_pretty(manifest)?;\n    crate::settings::atomic_write(&state_dir.join(MARKET_CACHE_FILE), &bytes)\n}\n\nfn read_cached_manifest(state_dir: &Path) -> anyhow::Result<DreamSkinMarketManifest> {\n    let path = state_dir.join(MARKET_CACHE_FILE);\n    let metadata = std::fs::metadata(&path)\n        .with_context(|| format!(\"主题市场缓存不存在：{}\", path.display()))?;\n    if metadata.len() > MARKET_INDEX_LIMIT as u64 {\n        bail!(\"主题市场缓存超过大小限制\");\n    }\n    let mut manifest: DreamSkinMarketManifest =\n        serde_json::from_slice(&std::fs::read(&path)?).context(\"主题市场缓存不是有效 JSON\")?;","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_market.rs#L261-L297","documentation":"After successfully streaming an HTTP response in `download_limited`, the library rejects the result if zero bytes were received. An empty body cannot be a valid market manifest JSON or theme asset (image), so it is treated as a failed download rather than propagating empty data to JSON parsing or file writing.","triggerScenarios":"`fetch_market_manifest` or `install_market_theme_from_base` receiving an HTTP 2xx response with a zero-length body (e.g. a 204 No Content, an empty success page from a misconfigured proxy, or a server that lost its file but still returns 200).","commonSituations":"Reverse proxy or CDN returning empty 200 responses when the origin file is missing; uploading a 0-byte manifest/asset to the market host; captive portals or intercepting proxies returning empty success bodies; truncated uploads.","solutions":["Check the market server: the file at the URL is likely 0 bytes or missing — re-upload or restore the correct manifest/theme asset.","Re-fetch the market index (clear the cached manifest in the state dir) to rule out a stale/bad cache cycle.","Test the URL directly with `curl -v` to confirm the server returns a non-empty body; fix proxy/CDN configuration if it strips the body.","If the asset URL in the manifest is wrong (pointing at an empty endpoint), correct the manifest and republish."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in 0..3 {\n    match download_limited(&client, &url, LIMIT).await {\n        Err(e) if e.to_string().contains(\"下载内容为空\") => continue, // transient empty 200\n        other => { other?; break; }\n    }\n}","preventionTips":["Verify market server files are non-zero bytes after upload (ci check on artifact size)","Fix reverse-proxy/CDN configs that return empty 200s when origin files are missing","Treat empty 204/200 responses as failed fetches and fall back to the cached manifest","Monitor the market host for 0-byte files and missing-asset alerts"],"tags":["network","http","download","empty-response"],"backgroundTag":"empty-response-body","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"}