BigPizzaV3/CodexPlusPlus · error

下载内容超过 字节限制

Error message

下载内容超过 {} 字节限制

What it means

`download_limited` performs a size-capped HTTP download. Before streaming, it checks the `Content-Length` response header; if the server declares a body larger than the configured `limit`, the download is aborted immediately. This protects the app from unbounded memory use when a market manifest or theme asset is unexpectedly huge.

Solutions

  1. Check the URL being fetched: if it is wrong (e.g. pointing at a full archive instead of a small index), correct the market base URL or asset path in the manifest.
  2. If the resource is legitimately large, increase the configured size limit passed to `download_limited` (e.g. the `MARKET_INDEX_LIMIT`-style constant for manifests) in the caller.
  3. Verify with `curl -I <url>` what the server reports as Content-Length and fix the server-side file if it was replaced by a larger one.
  4. For chunked/unknown-length oversized responses, the equivalent stream-phase check (error at line 274) will fire; the fix is the same.
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight with reqwest::Client::new()
let len = client.head(url).send().await?.content_length();
if let Some(n) = len {
    anyhow::ensure!(n <= limit, "resource too large: {n} > {limit}");
}

Try / catch

match download_limited(&client, &url, LIMIT).await {
    Err(e) if e.to_string().contains("字节限制") => {
        // skip this asset / surface size error to user
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `fetch_market_manifest` or `install_market_theme_from_base` (which route through `download_limited`) against a URL whose response declares `Content-Length` greater than the limit (manifest limit or asset limit). Requires the server to send a Content-Length header (chunked responses skip this check and hit error 162 instead).

Common situations: A misconfigured or malicious market server pointing the manifest at a multi-gigabyte file; a theme asset URL that actually hosts an archive far larger than the allowed theme/image size; a redirect landing on the wrong resource.

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/acd1c4a51cc6b8a5. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_market.rs:267

}

async fn download_limited(
    client: &reqwest::Client,
    url: &str,
    limit: usize,
) -> anyhow::Result<Vec<u8>> {
    let response = client
        .get(url)
        .send()
        .await
        .with_context(|| format!("请求失败:{url}"))?
        .error_for_status()
        .with_context(|| format!("服务器返回错误状态:{url}"))?;
    if response
        .content_length()
        .is_some_and(|size| size > limit as u64)
    {
        bail!("下载内容超过 {} 字节限制", limit);
    }
    let mut stream = response.bytes_stream();
    let mut bytes = Vec::new();
    while let Some(chunk) = stream.next().await {
        let chunk = chunk.context("读取下载内容失败")?;
        if bytes.len().saturating_add(chunk.len()) > limit {
            bail!("下载内容超过 {} 字节限制", limit);
        }
        bytes.extend_from_slice(&chunk);
    }
    if bytes.is_empty() {
        bail!("下载内容为空");
    }
    Ok(bytes)
}

fn cache_manifest(state_dir: &Path, manifest: &DreamSkinMarketManifest) -> anyhow::Result<()> {
    let bytes = serde_json::to_vec_pretty(manifest)?;

View on GitHub (pinned to b1ed92e5e4)