Zackriya-Solutions/meetily · error

Invalid Content-Length header encoding: {}

Error message

Invalid Content-Length header encoding: {}

What it means

Thrown by `declared_content_length` in the Parakeet model downloader when the Content-Length response header exists but is not valid ASCII (reqwest's `HeaderValue::to_str()` fails). The header value is only allowed to contain visible ASCII characters; non-ASCII bytes make it unreadable as a number. This is a defensive check while probing the model server before downloading.

Source

Thrown at frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs:719

            request = request.header(reqwest::header::RANGE, format!("bytes={range_start}-"));
        }

        tokio::select! {
            biased;
            _ = active_download.cancellation.cancelled() => Err(DownloadCancelled.into()),
            response = request.send() => response
                .map_err(|error| anyhow!("Failed to start download for {}: {}", file_url, error)),
        }
    }

    fn declared_content_length(response: &reqwest::Response) -> Result<Option<u64>> {
        response
            .headers()
            .get(reqwest::header::CONTENT_LENGTH)
            .map(|value| {
                value
                    .to_str()
                    .map_err(|error| anyhow!("Invalid Content-Length header encoding: {}", error))?
                    .parse()
                    .map_err(|error| anyhow!("Invalid Content-Length header: {}", error))
            })
            .transpose()
    }

    fn validate_full_response(response: &reqwest::Response, exact_bytes: u64) -> Result<()> {
        if response.status() != reqwest::StatusCode::OK {
            return Err(anyhow!(
                "Expected full 200 response, received {}",
                response.status()
            ));
        }
        if let Some(content_length) = Self::declared_content_length(response)? {
            if content_length != exact_bytes {
                return Err(anyhow!(
                    "Full response declared {} bytes, expected {}",
                    content_length,

View on GitHub (pinned to a2cb62e827)

Solutions

  1. Bypass the proxy/CDN and request the model URL directly to see if the header is clean.
  2. Verify the model server (or mirror URL configured for the Parakeet download) sends a proper numeric Content-Length.
  3. Retry the download; transient corruption at an intermediary is often intermittent.
  4. Use an alternate download mirror for the model.

Example fix

// before: hard-fail on any header encoding problem
value.to_str().map_err(|e| anyhow!("Invalid Content-Length header encoding: {}", e))?;
// after: tolerate undecodable headers by treating length as unknown
let len = value.to_str().ok().and_then(|s| s.parse::<u64>().ok());
Defensive patterns

Strategy: validation

Validate before calling

let resp = client.head(url).send().await?;
let bad_cl = resp.headers().get("content-length")
    .map(|v| v.to_str().map_err(|_| "non-ascii content-length").and_then(|s| s.parse::<u64>().map_err(|_| "non-numeric content-length")).is_err())
    .unwrap_or(false);
if bad_cl { eprintln!("mirror sends invalid Content-Length; pick another mirror"); }

Type guard

fn valid_content_length(v: &reqwest::header::HeaderValue) -> Option<u64> {
    v.to_str().ok()?.parse::<u64>().ok()
}

Try / catch

match result {
    Err(e) if e.to_string().contains("Invalid Content-Length header encoding") => fallback_to_mirror(),
    other => other,
}

Prevention

When it happens

Trigger: A HEAD or GET request to the model URL returns a Content-Length header whose raw bytes are not valid visible ASCII (e.g. corrupted proxy-injected header, misbehaving CDN, or binary garbage in the header).

Common situations: Requests routed through a misconfigured reverse proxy or corporate proxy that rewrites headers; a compromised or non-standard HTTP server; header value mangled in transit.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@a2cb62e827 (2026-09-12). Data as JSON: /api/errors/cad1833ab6aac827. Report an issue: GitHub.