Hmbown/CodeWhale · error · PersistenceBacklogMeasurementError

exact library measurement test

Error message

exact library measurement test {TEST_NAME} emitted no valid receipt: {error}

What it means

After the test run, the script reads the receipt JSON file the test is supposed to write and wraps any failure to find or parse it into PersistenceBacklogMeasurementError, chaining the underlying OSError or JSONDecodeError. It means the test ran but produced no readable, valid receipt.

Solutions

  1. Run the exact test (cargo test <TEST_NAME>) directly and check whether it writes the receipt and where
  2. Delete the stale/corrupt receipt and re-run so the test writes it fresh
  3. Fix filesystem issues: correct working directory, write permissions, free disk space
  4. If the JSON is malformed, fix the test's receipt-serialization code

Example fix

// before (read)
receipt_path = Path("receipt.json")  # stale from previous run
// after
receipt_path.unlink(missing_ok=True)  # then re-run so the test writes a fresh receipt
Defensive patterns

Strategy: try-catch

Validate before calling

receipt = Path("receipt.json")
receipt.unlink(missing_ok=True)
# after running the test:
assert receipt.exists() and receipt.stat().st_size > 0
json.loads(receipt.read_text(encoding="utf-8"))

Try / catch

try:
    receipt = run_measurement()
except PersistenceBacklogMeasurementError as e:
    log.error("measurement receipt missing/invalid: %s", e)

Prevention

When it happens

Trigger: The receipt file was not written (test didn't reach the write, wrong cwd, no permission), the path is stale, or the file contains invalid/truncated JSON.

Common situations: Test failed mid-run after the harness reported started; running the script from a different working directory than the receipt path expects; a previous crash left a corrupt receipt; disk-full or permission issues.

Understand the failure class

Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/8e3b872bf2d98fdb. Report an issue: GitHub.

Appendix: source

Thrown at scripts/measure-persistence-backlog.py:77

        text=True,
        capture_output=True,
        check=False,
    )
    sys.stderr.write(result.stderr)
    if result.returncode != 0:
        sys.stdout.write(result.stdout)
        result.check_returncode()

    combined = "\n".join(result.stdout.splitlines() + result.stderr.splitlines())
    if re.search(r"\brunning\s+0\s+tests?\b", combined):
        sys.stdout.write(result.stdout)
        raise PersistenceBacklogMeasurementError(
            f"exact library measurement test {TEST_NAME} ran zero tests"
        )
    try:
        return json.loads(receipt_path.read_text(encoding="utf-8"))
    except (OSError, json.JSONDecodeError) as error:
        raise PersistenceBacklogMeasurementError(
            f"exact library measurement test {TEST_NAME} emitted no valid receipt: {error}"
        ) from error


def main() -> int:
    source_sha = subprocess.run(
        ["git", "rev-parse", "HEAD"],
        cwd=ROOT,
        text=True,
        capture_output=True,
        check=True,
    ).stdout.strip()
    source_dirty = bool(
        subprocess.run(
            ["git", "status", "--porcelain", "--untracked-files=normal"],
            cwd=ROOT,
            text=True,
            capture_output=True,

View on GitHub (pinned to 433685b202)