Hmbown/CodeWhale · error · RuntimeError

Codewhale terminal receipt omitted a valid

Error message

Codewhale terminal receipt omitted a valid {field}

What it means

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.

Solutions

  1. Log the terminal receipt and check which field failed and its exact value
  2. Fix the binary to emit full 64-hex-char lowercase SHA-256 digests with no `sha256:` prefix
  3. Regenerate the receipt if hashes were truncated by a size cap in `_bounded_terminal`
  4. Update fixtures/mocks to use real 64-character hex strings for both fields

Example fix

// before
{"receipt_kind":"terminal","binary_sha256":"sha256:9f86d081...","prompt_sha256":""}
// after
{"receipt_kind":"terminal","binary_sha256":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08","prompt_sha256":"<64 hex chars>"}
Defensive patterns

Strategy: validation

Validate before calling

import re
SHA = re.compile(r"[0-9a-fA-F]{64}")
for f in ("binary_sha256", "prompt_sha256"):
    v = terminal.get(f)
    assert isinstance(v, str) and SHA.fullmatch(v), f"{f} invalid: {v!r}"

Type guard

def has_valid_sha256(terminal: dict, field: str) -> bool:
    import re
    v = terminal.get(field)
    return isinstance(v, str) and re.fullmatch(r"[0-9a-fA-F]{64}", v) is not None

Try / catch

try:
    receipt = _parse_stream_receipt(events)
except RuntimeError as e:
    if "omitted a valid" in str(e):
        log.error(f"terminal receipt hash invalid: {e}")
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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 `"..."`.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/d96d0935d2bf39bd. Report an issue: GitHub.

Appendix: source

Thrown at integrations/verifiers-codewhale/codewhale_harness/harness.py:389

        if event_type == "metadata":
            if terminal is not None:
                raise RuntimeError("Codewhale emitted more than one terminal metadata receipt")
            meta = event.get("meta")
            if not isinstance(meta, dict) or meta.get("receipt_kind") != "terminal":
                raise RuntimeError("Codewhale metadata event was not a terminal receipt")
            terminal = _bounded_terminal(meta)

    if terminal is None:
        raise RuntimeError("Codewhale stream-json omitted terminal metadata")
    if counts["done"] != 1 or not ordered_types or ordered_types[-1] != "done":
        raise RuntimeError("Codewhale stream-json did not end with exactly one done event")
    if ordered_types[-2:-1] != ["metadata"]:
        raise RuntimeError("Codewhale terminal metadata did not immediately precede done")
    for field in ["binary_sha256", "prompt_sha256"]:
        if not isinstance(terminal.get(field), str) or not _SHA256.fullmatch(
            terminal[field]
        ):
            raise RuntimeError(f"Codewhale terminal receipt omitted a valid {field}")
    return {
        "schema": STREAM_SCHEMA,
        "schema_version": STREAM_SCHEMA_VERSION,
        "events": dict(sorted(counts.items())),
        "terminal": terminal,
    }

View on GitHub (pinned to 433685b202)