{"record":{"id":"2361d420ad8436e1","repo":"Hmbown/CodeWhale","slug":"receipt-missing-required-field-s-joined-missing-fields","errorCode":null,"errorMessage":"receipt missing required field(s): <joined missing fields>","messagePattern":"receipt missing required field\\(s\\): <joined missing fields>","errorType":"validation","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":144,"sourceCode":"        \"source_dirty\": bool(\n            run([\"git\", \"status\", \"--porcelain\", \"--untracked-files=normal\"])\n        ),\n        \"rustc_version\": run([\"rustc\", \"--version\"]),\n        \"cargo_version\": run([\"cargo\", \"--version\"]),\n        \"build_profile\": \"test\",\n        \"sample_count\": 1,\n    }\n\n\ndef validate_receipt(\n    receipt: dict[str, Any],\n    *,\n    expected_source: dict[str, Any] | None = None,\n    require_clean_source: bool = False,\n) -> None:\n    missing = [field for field in REQUIRED_RECEIPT_FIELDS if field not in receipt]\n    if missing:\n        raise PersistenceBacklogError(\n            \"receipt missing required field(s): \" + \", \".join(missing)\n        )\n    if receipt[\"document_kind\"] != RECEIPT_KIND:\n        raise PersistenceBacklogError(f\"receipt document_kind must be {RECEIPT_KIND}\")\n    if receipt[\"schema_version\"] != SCHEMA_VERSION:\n        raise PersistenceBacklogError(\"receipt schema_version changed\")\n    for field, expected in FIXTURE.items():\n        validate_frozen_field(field, receipt[field], expected)\n    if not isinstance(receipt[\"source_sha\"], str) or not SOURCE_SHA_PATTERN.fullmatch(\n        receipt[\"source_sha\"]\n    ):\n        raise PersistenceBacklogError(\"receipt source_sha must be an exact lowercase Git SHA\")\n    if type(receipt[\"source_dirty\"]) is not bool:\n        raise PersistenceBacklogError(\"receipt source_dirty must be boolean\")\n    for field, prefix in ((\"rustc_version\", \"rustc \"), (\"cargo_version\", \"cargo \")):\n        if not isinstance(receipt[field], str) or not receipt[field].startswith(prefix):\n            raise PersistenceBacklogError(f\"receipt {field} must be a version string\")\n    validate_frozen_field(\"build_profile\", receipt[\"build_profile\"], \"test\")","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L126-L162","documentation":"`validate_receipt` checks that every field in `REQUIRED_RECEIPT_FIELDS` is present in a persistence backlog receipt. If any of the ~29 required fields (document_kind, schema_version, source_sha, RSS counters, fixture fields, etc.) are absent from the JSON object, this error lists the missing names. The receipt format is a frozen contract, so a partial receipt is rejected before any value-level validation.","triggerScenarios":"Passing `--receipt <path>` with a JSON file that omits required keys; hand-editing a receipt and deleting a field; an older measurement script producing a schema with fewer fields; feeding the baseline receipt from another project.","commonSituations":"Receipts written by an older schema version before new fields (e.g. rss_during_delta_bytes) were added; a user copying a receipt template and dropping fields; JSON manually trimmed to shrink a diff.","solutions":["Regenerate the receipt by running the measurement script (`check-persistence-backlog-budget.py` without --receipt) instead of hand-authoring it","Add the fields named in the error message to the receipt JSON, copying values from a fresh measurement run","Check `scripts/persistence-backlog-baseline-receipt.json` as a reference for the full required field set","Upgrade the receipt producer (scripts/measure-persistence-backlog.py) so it emits the current schema"],"exampleFix":"// before (receipt.json)\n{\"document_kind\": \"codewhale.persistence_backlog_receipt\", \"schema_version\": 2}\n// after\n{\"document_kind\": \"codewhale.persistence_backlog_receipt\", \"schema_version\": 2, \"source_sha\": \"...\", \"source_dirty\": false, \"rustc_version\": \"rustc 1.0\", \"cargo_version\": \"cargo 1.0\", \"build_profile\": \"test\", \"sample_count\": 1, \"platform\": \"linux\", \"limitations\": [\"...\"], \"accepted_requests\": 128, \"requests_attempted\": 128}","handlingStrategy":"validation","validationCode":"REQUIRED = (\"document_kind\",\"schema_version\",\"source_sha\",\"source_dirty\",\"rustc_version\",\"cargo_version\",\"build_profile\",\"sample_count\",\"fixture_id\",\"platform\",\"request_variant\",\"payload_estimator\",\"paused_consumer\",\"requests_attempted\",\"content_bytes_per_request\",\"single_session_id\",\"expected_applied_version\",\"accepted_requests\",\"retained_queued_requests\",\"estimated_retained_payload_bytes\",\"applied_version\",\"final_version_applied\",\"enqueue_elapsed_ns\",\"rss_supported\",\"rss_before_bytes\",\"rss_during_bytes\",\"rss_after_bytes\",\"rss_during_delta_bytes\",\"rss_after_delta_bytes\",\"limitations\")\nmissing = [f for f in REQUIRED if f not in receipt]\nassert not missing, f\"missing fields: {missing}\"","typeGuard":"def is_complete_receipt(r):\n    return isinstance(r, dict) and all(f in r for f in (\"document_kind\",\"schema_version\",\"source_sha\",\"platform\",\"limitations\"))","tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept PersistenceBacklogError as e:\n    if str(e).startswith(\"receipt missing required field\"):\n        receipt = regenerate_receipt()","preventionTips":["Regenerate receipts with the measurement script instead of hand-authoring them","Keep receipt producers and the checker on the same commit","Diff a new receipt against scripts/persistence-backlog-baseline-receipt.json for the field set","Never delete fields from receipts to shrink diffs"],"tags":["validation","json","schema","receipt"],"backgroundTag":"missing-required-config-field","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"}