{"record":{"id":"fd1d61e1f6e4002e","repo":"headroomlabs-ai/headroom","slug":"could-not-find-a-rev-for-ruff-pre-commit-repo","errorCode":null,"errorMessage":"could not find a rev for {RUFF_PRE_COMMIT_REPO}","messagePattern":"could not find a rev for (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/verify-ruff-version.py","lineNumber":63,"sourceCode":"    versions = [str(package[\"version\"]) for package in packages if package[\"name\"] == \"ruff\"]\n    if len(versions) != 1:\n        raise ValueError(f\"expected one locked Ruff package, found {versions!r}\")\n    return versions[0]\n\n\ndef _pre_commit_version() -> str:\n    lines = (ROOT / \".pre-commit-config.yaml\").read_text(encoding=\"utf-8\").splitlines()\n    for index, line in enumerate(lines):\n        if line.strip() != f\"- repo: {RUFF_PRE_COMMIT_REPO}\":\n            continue\n        for candidate in lines[index + 1 :]:\n            stripped = candidate.strip()\n            if stripped.startswith(\"- repo:\"):\n                break\n            if stripped.startswith(\"rev:\"):\n                return stripped.removeprefix(\"rev:\").strip().removeprefix(\"v\")\n        break\n    raise ValueError(f\"could not find a rev for {RUFF_PRE_COMMIT_REPO}\")\n\n\ndef _workflow_errors() -> list[str]:\n    workflow = (ROOT / \".github/workflows/ci.yml\").read_text(encoding=\"utf-8\")\n    errors = []\n    if WORKFLOW_VERSION_COMMAND not in workflow:\n        errors.append(f\"ci.yml does not run {WORKFLOW_VERSION_COMMAND!r}\")\n    if WORKFLOW_INSTALL_REFERENCE not in workflow:\n        errors.append(f\"ci.yml does not install Ruff from {WORKFLOW_INSTALL_REFERENCE!r}\")\n    return errors\n\n\ndef _parse_args() -> argparse.Namespace:\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\n        \"--print-version\",\n        action=\"store_true\",\n        help=\"print the authoritative version after validating every execution path\",","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/scripts/verify-ruff-version.py#L45-L81","documentation":"verify-ruff-version.py scans `.pre-commit-config.yaml` for the Ruff hook repo (`- repo: <RUFF_PRE_COMMIT_REPO>`) and reads the next `rev:` line before the following `- repo:` entry. The error means either the repo entry is missing entirely, or it exists with no `rev:` key — so the pre-commit Ruff version cannot be compared against pyproject.toml.","triggerScenarios":"Removing the Ruff pre-commit hook; renaming the repo URL so the exact `- repo: https://github.com/astral-sh/ruff-pre-commit` line no longer matches; adding the hook without a `rev:`; `rev:` appearing after a nested `- repo:` list item.","commonSituations":"Pre-commit config refactors that switch to a local hook wrapper or a mirror URL; pre-commit autoupdate rewriting the entry into a shape the parser skips; indentation changes making the `rev:` line not match the scan window.","solutions":["Open `.pre-commit-config.yaml` and confirm the exact repo line matches RUFF_PRE_COMMIT_REPO (same URL, same `- repo: ` prefix).","Add/restore `rev: v<X.Y.Z>` directly under that repo entry, matching the pinned Ruff version.","Keep `rev:` between the `- repo:` line and the next `- repo:` line — the parser stops scanning at the next repo entry."],"exampleFix":"# .pre-commit-config.yaml - before\nrepos:\n  - repo: https://github.com/astral-sh/ruff-pre-commit\n    hooks:\n      - id: ruff\n\n# after\nrepos:\n  - repo: https://github.com/astral-sh/ruff-pre-commit\n    rev: v0.5.0\n    hooks:\n      - id: ruff","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nRUFF_REPO = \"https://github.com/astral-sh/ruff-pre-commit\"\n\ndef pre_commit_ruff_rev(config: Path) -> str | None:\n    lines = config.read_text().splitlines()\n    for i, line in enumerate(lines):\n        if line.strip() == f\"- repo: {RUFF_REPO}\":\n            for cand in lines[i + 1:]:\n                s = cand.strip()\n                if s.startswith(\"- repo:\"):\n                    break\n                if s.startswith(\"rev:\"):\n                    return s.removeprefix(\"rev:\").strip().removeprefix(\"v\")\n    return None\n# assert pre_commit_ruff_rev(...) == pinned_version in CI","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the exact upstream repo URL for the Ruff pre-commit hook; do not substitute mirrors.","Always place `rev:` directly under the `- repo:` entry.","Run `pre-commit autoupdate` and verify-ruff-version.py together when upgrading Ruff."],"tags":["pre-commit","ruff","config","yaml"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}