{"record":{"id":"b8d9a67dcb385bcc","repo":"headroomlabs-ai/headroom","slug":"bedrock-eventstream-crc-mismatch","errorCode":"bedrock_eventstream_crc_mismatch","errorMessage":"prelude CRC mismatch: expected={expected:#010x} got={got:#010x}","messagePattern":"prelude CRC mismatch: expected=(.+?) got=(.+?)","errorType":"exception","errorClass":"ParseError::PreludeCrcMismatch","httpStatus":null,"severity":"error","filePath":"crates/headroom-proxy/src/bedrock/eventstream.rs","lineNumber":164,"sourceCode":"    /// requires (12-byte prelude, headers block, 4-byte trailing CRC).\n    /// Wire-format violation; AWS would never emit this. Surfaced\n    /// loudly so the handler can 5xx and log it.\n    #[error(\n        \"implausible prelude lengths: total_length={total_length}, headers_length={headers_length}\"\n    )]\n    ImplausiblePreludeLengths {\n        total_length: u32,\n        headers_length: u32,\n    },\n    /// `total_length` exceeds the configured `max_message_bytes` cap.\n    /// The cap defaults to 32 MiB; configurable via\n    /// [`EventStreamParser::with_max_message_bytes`].\n    #[error(\"message too large: total_length={total_length} cap={cap}\")]\n    MessageTooLarge { total_length: u32, cap: usize },\n    /// CRC32 of the first 8 bytes of the prelude did not match the\n    /// 9th-12th bytes. Indicates corruption (in-flight bit-flip,\n    /// truncated chunk, or — if persistent — wire-format version skew).\n    #[error(\"prelude CRC mismatch: expected={expected:#010x} got={got:#010x}\")]\n    PreludeCrcMismatch { expected: u32, got: u32 },\n    /// CRC32 of the entire message body did not match the trailing\n    /// 4-byte CRC. Indicates the message bytes were corrupted in\n    /// flight.\n    #[error(\"message CRC mismatch: expected={expected:#010x} got={got:#010x}\")]\n    MessageCrcMismatch { expected: u32, got: u32 },\n    /// A header's `name_len` extended past the declared end of the\n    /// headers block.\n    #[error(\"truncated header at offset {offset}: needs {needed} more bytes\")]\n    TruncatedHeader { offset: usize, needed: usize },\n    /// A header's name was not valid UTF-8.\n    #[error(\"header name not valid UTF-8 at offset {offset}: {source}\")]\n    HeaderNameNotUtf8 {\n        offset: usize,\n        #[source]\n        source: std::str::Utf8Error,\n    },\n    /// A string-typed header value was not valid UTF-8.","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/crates/headroom-proxy/src/bedrock/eventstream.rs#L146-L182","documentation":"The HEADROOM_MEMORY_INJECTION_MODE environment variable is set to something other than 'live_zone_tail' or 'disabled' (memory_injection_mode_policy.py:19). Values are trimmed/lowercased, so 'Live_Zone_Tail' is fine, but 'on', 'off', 'true', 'none', or typos fail fast at config resolution.","triggerScenarios":"Exporting HEADROOM_MEMORY_INJECTION_MODE=0/1 in a start script; a k8s ConfigMap carrying boolean-style values; typo 'live-zone-tail' (hyphens instead of underscores).","commonSituations":"Boolean-env-var conventions colliding with enum-valued config; template normalization of all toggles to true/false; hyphen/underscore confusion copied from docs.","solutions":["Set the variable to 'live_zone_tail' or 'disabled', or unset it (defaults to live_zone_tail)","Check: echo $HEADROOM_MEMORY_INJECTION_MODE and fix the value in .env/compose/manifest","If you meant to turn it off, the word is 'disabled', not 'false' or 'off'"],"exampleFix":"# before\nHEADROOM_MEMORY_INJECTION_MODE=false\n\n# after\nHEADROOM_MEMORY_INJECTION_MODE=disabled","handlingStrategy":"validation","validationCode":"raw = os.environ.get(\"HEADROOM_MEMORY_INJECTION_MODE\")\nif raw is not None and raw.strip().lower() not in (\"live_zone_tail\", \"disabled\"):\n    raise SystemExit(f\"bad HEADROOM_MEMORY_INJECTION_MODE={raw!r}; use live_zone_tail/disabled\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use underscores, not hyphens, in the enum value","Prefer 'disabled' over boolean-style 'false'/'off'/'0'"],"tags":["configuration","environment-variables","memory","startup"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}