{"record":{"id":"c018cdf65f6d10ae","repo":"Hmbown/CodeWhale","slug":"baseline-ref-ref-r-is-unavailable-commit-stderr-strip","errorCode":null,"errorMessage":"baseline ref {ref!r} is unavailable: {commit.stderr.strip()}","messagePattern":"baseline ref (.+?) is unavailable: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/check-command-migration-manifest.py","lineNumber":501,"sourceCode":"        return [ManifestViolation(\n            \"frontier-projection\",\n            \"PENDING_GROUPS\",\n            f\"TUI projection {pending!r} does not equal JSON frontier {doc.get('frontier')!r}\",\n        )]\n    return []\n\n\ndef load_topology_at_ref(ref: str, root: Path = REPO_ROOT) -> dict | None:\n    \"\"\"Load the topology from a Git revision; return None before its introduction.\"\"\"\n    commit = subprocess.run(\n        [\"git\", \"rev-parse\", \"--verify\", f\"{ref}^{{commit}}\"],\n        cwd=root,\n        capture_output=True,\n        text=True,\n        check=False,\n    )\n    if commit.returncode != 0:\n        raise ValueError(f\"baseline ref {ref!r} is unavailable: {commit.stderr.strip()}\")\n    shown = subprocess.run(\n        [\"git\", \"show\", f\"{ref}:{TOPOLOGY_REPO_PATH}\"],\n        cwd=root,\n        capture_output=True,\n        text=True,\n        check=False,\n    )\n    if shown.returncode != 0:\n        return None\n    return json.loads(shown.stdout)\n\n\ndef validate_baseline_transition(current: dict, previous: dict | None) -> list[ManifestViolation]:\n    \"\"\"Enforce immutable topology and shrink-or-declared-split across revisions.\"\"\"\n    if validate_topology_document(current):\n        return [ManifestViolation(\n            \"current\",\n            \"topology\",","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-command-migration-manifest.py#L483-L519","documentation":"load_topology_at_ref verifies a baseline git ref (branch, tag, or commit) exists by running git rev-parse before reading the topology file at that ref. When the rev-parse exits nonzero it raises ValueError embedding git's stderr, because the checker cannot compare the current manifest against a baseline that does not resolve in this repository.","triggerScenarios":"Running the migration-manifest checker with a baseline ref that is missing locally: a typo'd branch/tag, a ref that exists only on the remote (not fetched), a shallow clone lacking history, or a commit that was garbage-collected.","commonSituations":"CI checkout with depth=1 or single-branch so the baseline branch is absent; renamed/deleted baseline branch; running in a fresh worktree without fetching tags; passing main when the repo uses master (or vice versa).","solutions":["Run git fetch --all (or git fetch origin <ref>) so the baseline ref exists locally","Fix the ref spelling passed to the checker","Use a ref that exists in a shallow checkout, or unshallow the clone (git fetch --unshallow)","Verify with git rev-parse <ref> manually before re-running the checker"],"exampleFix":"# before\npython scripts/check-command-migration-manifest.py --baseline origin/main\n# after\ngit fetch origin main\npython scripts/check-command-migration-manifest.py --baseline origin/main","handlingStrategy":"validation","validationCode":"import subprocess\nr = subprocess.run([\"git\", \"rev-parse\", \"--verify\", ref], capture_output=True, text=True)\nassert r.returncode == 0, f\"baseline ref {ref} missing: run git fetch origin {ref}\"","typeGuard":null,"tryCatchPattern":"try:\n    topology = load_topology_at_ref(root, ref)\nexcept ValueError as exc:\n    print(exc)  # includes git stderr\n    sys.exit(2)","preventionTips":["Fetch the baseline branch explicitly in CI before running the checker","Avoid shallow clones (or use --unshallow) for jobs that compare against a baseline","Keep the baseline branch name in one config constant, not inline strings","Verify refs with git rev-parse after any branch rename"],"tags":["git","cli","ref-resolution"],"backgroundTag":"git-command-failed","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"}