{"record":{"id":"99f4d0a1b5fef109","repo":"Hmbown/CodeWhale","slug":"measurement-command-failed","errorCode":null,"errorMessage":"measurement command failed","messagePattern":"measurement command failed","errorType":"console","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":386,"sourceCode":"            decreases.append((field, current, ceiling))\n    return increases, decreases\n\n\ndef measure() -> dict[str, Any]:\n    env = os.environ.copy()\n    env[\"CARGO_NET_OFFLINE\"] = \"true\"\n    result = subprocess.run(\n        [sys.executable, str(MEASURE_SCRIPT)],\n        cwd=ROOT,\n        env=env,\n        text=True,\n        capture_output=True,\n        check=False,\n    )\n    sys.stderr.write(result.stderr)\n    if result.returncode != 0:\n        sys.stdout.write(result.stdout)\n        raise PersistenceBacklogError(\"measurement command failed\")\n    try:\n        receipt = json.loads(result.stdout)\n    except json.JSONDecodeError as error:\n        raise PersistenceBacklogError(f\"measurement emitted invalid JSON: {error}\") from error\n    if not isinstance(receipt, dict):\n        raise PersistenceBacklogError(\"measurement receipt must be an object\")\n    return receipt\n\n\ndef main() -> int:\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"--receipt\", type=Path, help=\"check an existing receipt\")\n    parser.add_argument(\"--budget\", type=Path, default=BUDGET_PATH)\n    args = parser.parse_args()\n    try:\n        expected_source = current_source_identity()\n        receipt = load_json(args.receipt, \"receipt\") if args.receipt else measure()\n        budget = load_json(args.budget, \"budget\")","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L368-L404","documentation":"measure() runs the measurement command via subprocess and this error is raised when that command exits with a non-zero return code. The receipt generation underlying the budget check failed before producing output; the command's stdout is flushed and its stderr was already forwarded so the real failure cause is visible in the log. This is a wrapper error — diagnose the underlying command, not this line.","triggerScenarios":"Running scripts/check-persistence-backlog-budget.py (without --receipt) when the subprocess that produces the measurement receipt exits non-zero — e.g. the measurement binary fails to build, the workspace has compile errors, or the measurement tool itself errors.","commonSituations":"Broken workspace state when the guard runs in CI; missing build artifacts; the measurement command path/config changed; running from a directory where the measurement command cannot execute.","solutions":["Read the stderr echoed by the script immediately above this error to find the real failure","Build/verify the measurement target manually (cargo build) before re-running the script","Re-run the script from the repository root with a clean workspace"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"result = subprocess.run(cmd, capture_output=True)\nif result.returncode != 0:\n    sys.stderr.write(result.stderr)\n    raise PersistenceBacklogError(f\"measurement command failed: rc={result.returncode}\")","preventionTips":["Ensure the measurement target builds before running the guard","Run the check from the repository root","Keep the measurement command's stderr separate so failures are diagnosable"],"tags":["python","subprocess","ci-guard","exit-code"],"backgroundTag":"command-not-found","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"}