{"record":{"id":"2e5b808ac3250d8c","repo":"Hmbown/CodeWhale","slug":"kind-field-join-path-must-be-a-lowercase-sha-256-digest","errorCode":null,"errorMessage":"{kind} field `{'.'.join(path)}` must be a lowercase SHA-256 digest","messagePattern":"(.+?) field `(.+?)` must be a lowercase SHA-256 digest","errorType":"exception","errorClass":"RuntimeContractError","httpStatus":null,"severity":"error","filePath":"scripts/check-runtime-contract-budget.py","lineNumber":250,"sourceCode":"            count = metric_value(document, (*base, \"tools\"), kind)\n            if count != len(names):\n                raise RuntimeContractError(\n                    f\"{kind} metric `{'.'.join((*base, 'tools'))}` must equal the \"\n                    f\"owned tool_names length ({len(names)})\"\n                )\n            digest = required_value(document, (*base, \"identity_sha256\"), kind)\n            expected = tool_identity_digest(names)\n            if digest != expected:\n                raise RuntimeContractError(\n                    f\"{kind} field `{'.'.join((*base, 'identity_sha256'))}` must \"\n                    \"match the owned sorted tool_names\"\n                )\n\n    for stage, _label in REPRESENTATIVE_STAGES:\n        path = (\"representative_context\", \"stages\", stage, \"identity_sha256\")\n        digest = required_value(document, path, kind)\n        if not isinstance(digest, str) or re.fullmatch(r\"[0-9a-f]{64}\", digest) is None:\n            raise RuntimeContractError(\n                f\"{kind} field `{'.'.join(path)}` must be a lowercase SHA-256 digest\"\n            )\n\n\ndef validate_receipt(receipt: dict[str, Any]) -> None:\n    validate_document(receipt, RECEIPT_KIND, \"receipt\")\n    skill_discovery = receipt.get(\"skill_discovery\")\n    identical = (\n        skill_discovery.get(\"prompts_byte_identical\")\n        if isinstance(skill_discovery, dict)\n        else None\n    )\n    if identical is not True:\n        raise RuntimeContractError(\n            \"receipt metric `skill_discovery.prompts_byte_identical` must be true\"\n        )\n    representative = receipt.get(\"representative_context\")\n    fixture_id = (","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-runtime-contract-budget.py#L232-L268","documentation":"Each representative_context.stages.<stage>.identity_sha256 must be a 64-character lowercase hex string, i.e. a canonical SHA-256 digest. This is a format check (not a value check) ensuring digests are copyable and comparable across receipts.","triggerScenarios":"A stage digest that is uppercase hex, shorter/longer than 64 chars, contains non-hex characters, or is not a string at all.","commonSituations":"Digest produced by hashlib.sha256().hexdigest().upper(); a truncated or truncated-prefixed digest; a placeholder string like \"<sha256>\" left in a template; digest written as bytes.","solutions":["Store digest.hexdigest() (lowercase, 64 chars) from hashlib.sha256","Fix the value to the exact 64-char lowercase hex string","Validate the format before writing: re.fullmatch(r\"[0-9a-f]{64}\", digest)"],"exampleFix":"// before\n\"identity_sha256\": \"ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890\"\n// after\n\"identity_sha256\": \"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890\"","handlingStrategy":"validation","validationCode":"import re\nfor stage, _ in REPRESENTATIVE_STAGES:\n    d = doc[\"representative_context\"][\"stages\"][stage][\"identity_sha256\"]\n    assert isinstance(d, str) and re.fullmatch(r\"[0-9a-f]{64}\", d), f\"bad digest for {stage}\"","typeGuard":"def is_sha256_hex(v) -> bool:\n    return isinstance(v, str) and re.fullmatch(r\"[0-9a-f]{64}\", v) is not None","tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept RuntimeContractError as e:\n    if \"lowercase SHA-256 digest\" in str(e):\n        print(\"digest format invalid; store hashlib hexdigest() output\")\n    raise","preventionTips":["Always use hashlib ...hexdigest(), never upper() or truncation","Add is_sha256_hex to your document-loading helper","Reject placeholder strings in templates before they reach receipts"],"tags":["python","format-validation","sha256"],"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"}