{"record":{"id":"24534c35f2e4fcd6","repo":"Hmbown/CodeWhale","slug":"invalid-label-path-error","errorCode":null,"errorMessage":"invalid {label} {path}: {error}","messagePattern":"invalid (.+?) (.+?): (.+?)","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":90,"sourceCode":"    \"enqueue_elapsed_ns\",\n    \"rss_during_delta_bytes\",\n    \"rss_after_delta_bytes\",\n)\nRSS_SAMPLE_FIELDS = (\"rss_before_bytes\", \"rss_during_bytes\", \"rss_after_bytes\")\nRSS_DELTA_FIELDS = (\"rss_during_delta_bytes\", \"rss_after_delta_bytes\")\nSUPPORTED_PLATFORMS = {\"linux\", \"macos\", \"windows\"}\nSOURCE_SHA_PATTERN = re.compile(r\"[0-9a-f]{40}\")\n\n\nclass PersistenceBacklogError(ValueError):\n    \"\"\"A receipt or budget broke the measurement contract.\"\"\"\n\n\ndef load_json(path: Path, label: str) -> dict[str, Any]:\n    try:\n        value = json.loads(path.read_text(encoding=\"utf-8\"))\n    except (OSError, json.JSONDecodeError) as error:\n        raise PersistenceBacklogError(f\"invalid {label} {path}: {error}\") from error\n    if not isinstance(value, dict):\n        raise PersistenceBacklogError(f\"{label} must be a JSON object\")\n    return value\n\n\ndef non_negative_integer(value: Any, field: str) -> int:\n    if isinstance(value, bool) or not isinstance(value, int) or value < 0:\n        raise PersistenceBacklogError(f\"{field} must be a non-negative integer\")\n    return value\n\n\ndef validate_frozen_field(field: str, value: Any, expected: Any) -> None:\n    if type(value) is not type(expected) or value != expected:\n        raise PersistenceBacklogError(\n            f\"receipt {field} must remain {expected!r}, got {value!r}\"\n        )\n\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L72-L108","documentation":"scripts/check-persistence-backlog-budget.py loads two JSON documents — the budget (scripts/persistence-backlog-budget.json) and the baseline receipt (scripts/persistence-backlog-baseline-receipt.json). load_json wraps their reading/parsing; this error means the file could not be read (OSError: missing, unreadable) or its text was not valid JSON (JSONDecodeError). The underlying error text is appended, and the exception type is PersistenceBacklogError (a ValueError).","triggerScenarios":"Running the checker when either JSON file is absent (fresh clone where the baseline receipt was never generated), truncated by an interrupted write, or contains a syntax error such as a trailing comma or single quotes. The label in the message tells you which file ('budget' vs 'baseline receipt').","commonSituations":"CI running the budget check before the receipt-generation step; hand-editing the budget JSON and leaving invalid syntax; a merge conflict resolved with conflict markers still inside the JSON; line-ending or BOM issues from Windows editors.","solutions":["Read the appended error detail: 'No such file or directory' means regenerate/restore the file; 'Expecting ...' points at the JSON syntax offset.","Validate the file standalone: python3 -m json.tool scripts/persistence-backlog-budget.json > /dev/null.","Regenerate the baseline receipt with the project's documented measurement step so the file exists and is complete.","Fix any merge-conflict markers or trailing commas, then re-run the check."],"exampleFix":"# before: budget.json with a trailing comma\n{\"max_files\": 5000,}\n# after\n{\"max_files\": 5000}","handlingStrategy":"try-catch","validationCode":"import json\nfrom pathlib import Path\n\ndef json_document_loads(path: Path) -> bool:\n    try:\n        json.loads(path.read_text(encoding=\"utf-8\"))\n        return True\n    except (OSError, json.JSONDecodeError):\n        return False","typeGuard":null,"tryCatchPattern":"from scripts.check_persistence_backlog_budget import PersistenceBacklogError\n\ntry:\n    budget = load_json(BUDGET_PATH, \"budget\")\nexcept PersistenceBacklogError as error:\n    logger.error(\"budget document unreadable: %s\", error)\n    raise SystemExit(2)  # fail the CI step, do not fall back to defaults","preventionTips":["Validate both JSON files with python3 -m json.tool after every edit.","Write budget/receipt files atomically (write temp, rename) so interrupted runs cannot leave truncation.","Run the receipt-generation step before the budget check in CI ordering."],"tags":["json","ci","validation","persistence-budget","config"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}