Hmbown/CodeWhale · error · RuntimeContractError
missing {kind}: {path}
Error message
missing {kind}: {path} What it means
load_json in scripts/check-runtime-contract-budget.py caught FileNotFoundError while reading the receipt or budget path. The checker needs scripts/runtime-contract-budget.json and, when --receipt is passed, the measurement receipt to exist before validation. The message echoes the exact missing path and its kind (receipt or budget).
Source
Thrown at scripts/check-runtime-contract-budget.py:163
*(
(
("representative_context", "stages", stage, "identity_sha256"),
f"representative {label} stage identity digest",
)
for stage, label in REPRESENTATIVE_STAGES
),
)
class RuntimeContractError(ValueError):
"""A receipt or budget is missing a required, well-typed metric."""
def load_json(path: Path, kind: str) -> dict[str, Any]:
try:
document = json.loads(path.read_text(encoding="utf-8"))
except FileNotFoundError as error:
raise RuntimeContractError(f"missing {kind}: {path}") from error
except (OSError, json.JSONDecodeError) as error:
raise RuntimeContractError(f"invalid {kind} {path}: {error}") from error
if not isinstance(document, dict):
raise RuntimeContractError(f"invalid {kind} {path}: top level must be an object")
return document
def validate_document(
document: dict[str, Any], expected_kind: str, source: str
) -> None:
actual_kind = document.get("document_kind")
if actual_kind != expected_kind:
raise RuntimeContractError(
f"{source} document_kind must be `{expected_kind}`, got {actual_kind!r}"
)
version = document.get("schema_version")
if (
isinstance(version, bool)View on GitHub (pinned to 8880682c63)
Solutions
- Check the path in the message with ls and fix typos — --receipt paths are resolved relative to where you invoke the script
- Generate a receipt first: run `python3 scripts/check-runtime-contract-budget.py` without --receipt, or run scripts/measure-runtime-contract.py
- Restore a deleted budget from git: `git checkout -- scripts/runtime-contract-budget.json`
Example fix
# before python3 scripts/check-runtime-contract-budget.py --receipt recipt.json # typo # after python3 scripts/check-runtime-contract-budget.py --receipt receipt.json
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
assert Path('scripts/runtime-contract-budget.json').is_file()
assert receipt_path.is_file(), receipt_path Prevention
- Validate paths before invoking the checker
- Generate receipts with the measure script instead of referencing stale files
- Use repo-root-relative paths in CI invocations
When it happens
Trigger: Passing --receipt with a typo'd or non-existent path; deleting scripts/runtime-contract-budget.json; running in a checkout that lacks the checked-in budget; using a relative path from the wrong working directory.
Common situations: Typos in CI invocations; fresh clones or partial checkouts missing files; scripts run outside the repository root.
Related errors
- baseline provenance build profile/sample count changed
- baseline receipt {field} does not match baseline_observation
- baseline receipt {field} does not match baseline provenance
- {kind} field `{dotted_names}` must be sorted unique non-empt
- measurement emitted invalid JSON: {error}
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/ea85d39fd85a2b73.
Report an issue: GitHub.