{"record":{"id":"d96d0935d2bf39bd","repo":"Hmbown/CodeWhale","slug":"codewhale-terminal-receipt-omitted-a-valid-field","errorCode":null,"errorMessage":"Codewhale terminal receipt omitted a valid {field}","messagePattern":"Codewhale terminal receipt omitted a valid (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":389,"sourceCode":"        if event_type == \"metadata\":\n            if terminal is not None:\n                raise RuntimeError(\"Codewhale emitted more than one terminal metadata receipt\")\n            meta = event.get(\"meta\")\n            if not isinstance(meta, dict) or meta.get(\"receipt_kind\") != \"terminal\":\n                raise RuntimeError(\"Codewhale metadata event was not a terminal receipt\")\n            terminal = _bounded_terminal(meta)\n\n    if terminal is None:\n        raise RuntimeError(\"Codewhale stream-json omitted terminal metadata\")\n    if counts[\"done\"] != 1 or not ordered_types or ordered_types[-1] != \"done\":\n        raise RuntimeError(\"Codewhale stream-json did not end with exactly one done event\")\n    if ordered_types[-2:-1] != [\"metadata\"]:\n        raise RuntimeError(\"Codewhale terminal metadata did not immediately precede done\")\n    for field in [\"binary_sha256\", \"prompt_sha256\"]:\n        if not isinstance(terminal.get(field), str) or not _SHA256.fullmatch(\n            terminal[field]\n        ):\n            raise RuntimeError(f\"Codewhale terminal receipt omitted a valid {field}\")\n    return {\n        \"schema\": STREAM_SCHEMA,\n        \"schema_version\": STREAM_SCHEMA_VERSION,\n        \"events\": dict(sorted(counts.items())),\n        \"terminal\": terminal,\n    }\n","sourceCodeStart":371,"sourceCodeEnd":396,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/integrations/verifiers-codewhale/codewhale_harness/harness.py#L371-L396","documentation":"After ordering checks, `_parse_stream_receipt` validates that the terminal receipt contains `binary_sha256` and `prompt_sha256` as strings matching the `_SHA256` regex (64 hex chars). This templated error names the offending field: the receipt either omitted the field, used a non-string, or supplied a malformed hash.","triggerScenarios":"The terminal metadata dict returned by `_bounded_terminal` lacks `binary_sha256` or `prompt_sha256`, contains them as a non-str type, or contains a value that is not exactly 64 lowercase/uppercase hex characters, triggering the raise at harness.py:389.","commonSituations":"Binary version whose receipt schema renamed or dropped the hash fields; hashes computed as uppercase-with-prefix or truncated (e.g. `sha256:abcd...` or 32-char md5); a mock receipt with placeholder values like `\"...\"`.","solutions":["Log the terminal receipt and check which field failed and its exact value","Fix the binary to emit full 64-hex-char lowercase SHA-256 digests with no `sha256:` prefix","Regenerate the receipt if hashes were truncated by a size cap in `_bounded_terminal`","Update fixtures/mocks to use real 64-character hex strings for both fields"],"exampleFix":"// before\n{\"receipt_kind\":\"terminal\",\"binary_sha256\":\"sha256:9f86d081...\",\"prompt_sha256\":\"\"}\n// after\n{\"receipt_kind\":\"terminal\",\"binary_sha256\":\"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08\",\"prompt_sha256\":\"<64 hex chars>\"}","handlingStrategy":"validation","validationCode":"import re\nSHA = re.compile(r\"[0-9a-fA-F]{64}\")\nfor f in (\"binary_sha256\", \"prompt_sha256\"):\n    v = terminal.get(f)\n    assert isinstance(v, str) and SHA.fullmatch(v), f\"{f} invalid: {v!r}\"","typeGuard":"def has_valid_sha256(terminal: dict, field: str) -> bool:\n    import re\n    v = terminal.get(field)\n    return isinstance(v, str) and re.fullmatch(r\"[0-9a-fA-F]{64}\", v) is not None","tryCatchPattern":"try:\n    receipt = _parse_stream_receipt(events)\nexcept RuntimeError as e:\n    if \"omitted a valid\" in str(e):\n        log.error(f\"terminal receipt hash invalid: {e}\")\n    raise","preventionTips":["Emit full 64-char lowercase hex digests without algorithm prefixes","Don't truncate hashes when bounding receipt size","Regenerate receipts after any schema change","Validate receipt hashes in producer tests"],"tags":["python","validation","checksum","hash-format","verifier-harness"],"backgroundTag":"invalid-argument-format","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}