{"record":{"id":"ad87071d1d46f2a2","repo":"headroomlabs-ai/headroom","slug":"ccr-redis-backend-init-failed-0","errorCode":null,"errorMessage":"ccr redis backend init failed: {0}","messagePattern":"ccr redis backend init failed: (.+?)","errorType":"exception","errorClass":"CcrBackendInitError","httpStatus":null,"severity":"error","filePath":"crates/headroom-core/src/ccr/backends/mod.rs","lineNumber":72,"sourceCode":"    pub fn in_memory_default() -> Self {\n        Self::InMemory {\n            capacity: crate::ccr::DEFAULT_CAPACITY,\n            ttl_seconds: crate::ccr::DEFAULT_TTL.as_secs(),\n        }\n    }\n}\n\n/// Reasons `from_config` may fail. Each variant is loud and recoverable\n/// at the proxy startup boundary — the operator is told exactly what\n/// went wrong rather than silently degrading to in-memory.\n#[derive(Debug, Error)]\npub enum CcrBackendInitError {\n    /// SQLite open / schema-create failed.\n    #[error(\"ccr sqlite backend init failed: {0}\")]\n    Sqlite(#[from] rusqlite::Error),\n    /// Redis open / PING failed (the smoke-test in `RedisCcrStore::open`).\n    #[cfg(feature = \"redis\")]\n    #[error(\"ccr redis backend init failed: {0}\")]\n    Redis(::redis::RedisError),\n    /// Operator selected a backend whose feature flag was not compiled\n    /// in. Loud failure rather than silent fallback.\n    #[error(\n        \"ccr backend `{backend}` is not compiled in; rebuild with `--features {feature}` \\\n         or pick a different backend\"\n    )]\n    UnsupportedBackend {\n        backend: &'static str,\n        feature: &'static str,\n    },\n}\n\n#[cfg(feature = \"redis\")]\nimpl From<::redis::RedisError> for CcrBackendInitError {\n    fn from(err: ::redis::RedisError) -> Self {\n        Self::Redis(err)\n    }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/crates/headroom-core/src/ccr/backends/mod.rs#L54-L90","documentation":"The 'zstandard' package IS installed, but decompressing the request body failed — the bytes are not a valid zstd stream. This is raised when ZstdDecompressor().stream_reader(raw).read() raises any non-ImportError exception (helpers.py:2411), e.g. zstandard.ZstdError for truncated or corrupted data.","triggerScenarios":"Client sets 'Content-Encoding: zstd' but the body was only partially uploaded (Content-Length mismatch, connection cut mid-request), double-compressed, or is actually gzip/plain bytes. Also happens when a proxy in front of headroom already decompressed the body but left the header intact.","commonSituations":"An intermediate nginx/envoy decodes the body but forwards the original Content-Encoding header; a client bug that compresses twice; middleware that mutates the body without updating headers.","solutions":["Reproduce with the same body and verify it decompresses standalone: python -c \"import zstandard,sys; zstandard.ZstdDecompressor().stream_reader(open('body.bin','rb').read()).read()\"","Fix or remove any intermediary that rewrites the body but keeps the Content-Encoding header","In the client, compress exactly once and set Content-Encoding: zstd only when the payload is actually zstd-compressed"],"exampleFix":"# before: header says zstd but body is plain JSON\nsession.post(url, data=payload, headers={\"Content-Encoding\": \"zstd\"})\n\n# after: compress the body or drop the header\nsession.post(url, data=zstandard.compress(payload), headers={\"Content-Encoding\": \"zstd\"})","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    body = await _read_request_body_bytes(request)\nexcept ValueError as exc:\n    if \"zstd\" in str(exc):\n        return JSONResponse({\"error\": \"invalid compressed body\"}, status_code=400)","preventionTips":["Verify compressed payloads round-trip before sending","Never let middleware alter a body without updating Content-Encoding","Log the first 4 bytes of failed bodies to fingerprint the actual format"],"tags":["compression","zstd","corrupt-body","request-body"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}