{"record":{"id":"d93040f3c9fcb84c","repo":"Hmbown/CodeWhale","slug":"receipt-field-must-be-a-version-string","errorCode":null,"errorMessage":"receipt {field} must be a version string","messagePattern":"receipt (.+?) must be a version string","errorType":"validation","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":161,"sourceCode":"    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\")\n    validate_frozen_field(\"sample_count\", receipt[\"sample_count\"], 1)\n    if expected_source is not None:\n        for field in (\n            \"source_sha\",\n            \"source_dirty\",\n            \"rustc_version\",\n            \"cargo_version\",\n            \"build_profile\",\n            \"sample_count\",\n        ):\n            if receipt[field] != expected_source[field]:\n                raise PersistenceBacklogError(\n                    f\"receipt {field} does not match the checked source\"\n                )\n    if require_clean_source and receipt[\"source_dirty\"]:\n        raise PersistenceBacklogError(\"persistence measurement source tree is dirty\")\n    platform = receipt[\"platform\"]","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L143-L179","documentation":"The `rustc_version` and `cargo_version` fields must be strings starting with the prefixes `\"rustc \"` and `\"cargo \"` respectively, mirroring the raw first line of `rustc --version` / `cargo --version`. The validator uses these to pin the receipt to the exact toolchain that produced the measurement. A missing toolchain identifier or a value that does not carry the expected prefix fails this check.","triggerScenarios":"A hand-written receipt stores just `\"1.75.0\"` or `\"rustc\"` without the prefix; the field is null or a number; the value was captured from a different command whose output lacks the prefix.","commonSituations":"Receipts authored by hand or by a script that reformatted the version output; recording only the version number instead of the full `rustc 1.75.0 (...)` line; generating receipts on a machine where the toolchain string is localized or wrapped.","solutions":["Store the full first line of `rustc --version`, e.g. `\"rustc 1.75.0 (82e1608df 2023-12-21)\"`","Store the full first line of `cargo --version`, e.g. `\"cargo 1.75.0 (1d8b05cdd 2023-11-20)\"`","Regenerate the receipt so `current_source_identity()` fills these fields from the actual toolchain"],"exampleFix":"// before\n\"rustc_version\": \"1.75.0\",\n\"cargo_version\": \"1.75.0\"\n// after\n\"rustc_version\": \"rustc 1.75.0 (82e1608df 2023-12-21)\",\n\"cargo_version\": \"cargo 1.75.0 (1d8b05cdd 2023-11-20)\"","handlingStrategy":"validation","validationCode":"assert str(receipt.get(\"rustc_version\", \"\")).startswith(\"rustc \"), receipt.get(\"rustc_version\")\nassert str(receipt.get(\"cargo_version\", \"\")).startswith(\"cargo \"), receipt.get(\"cargo_version\")","typeGuard":"def has_toolchain_strings(r):\n    return isinstance(r, dict) and isinstance(r.get(\"rustc_version\"), str) and r[\"rustc_version\"].startswith(\"rustc \") and isinstance(r.get(\"cargo_version\"), str) and r[\"cargo_version\"].startswith(\"cargo \")","tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept PersistenceBacklogError as e:\n    if \"must be a version string\" in str(e):\n        fill_versions_from_subprocess(receipt)  # rustc --version / cargo --version","preventionTips":["Store the raw first line of `rustc --version` and `cargo --version` verbatim","Never strip the \"rustc \"/\"cargo \" prefix to save space","Capture toolchain versions in the same run as the measurement"],"tags":["toolchain","validation","format","receipt"],"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"}