{"record":{"id":"a728dbd47e5dbfb2","repo":"abhigyanpatwari/GitNexus","slug":"could-not-resolve-the-committed-promotion-base","errorCode":null,"errorMessage":"could not resolve the committed promotion base","messagePattern":"could not resolve the committed promotion base","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":535,"sourceCode":"\ndef committed_destination_base_digests(\n    overlay: Path,\n    repo_root: Path = REPO_ROOT,\n    *,\n    ref: str = \"HEAD\",\n) -> dict[str, str]:\n    \"\"\"Bind targets to one immutable committed incumbent, never live edits.\"\"\"\n\n    _, payload = candidate_overlay_payload(overlay)\n    root, root_descriptor = _open_repository_root(repo_root)\n    os.close(root_descriptor)\n    rev = run_managed(\n        [\"git\", \"-C\", str(root), \"rev-parse\", f\"{ref}^{{commit}}\"],\n        timeout=60,\n        capture_stdout_bytes=256,\n    )\n    if not rev.ok or rev.stdout_capture_overflow or rev.stdout_capture is None:\n        raise ValueError(\"could not resolve the committed promotion base\")\n    commit = rev.stdout_capture.decode(\"ascii\", errors=\"strict\").strip()\n    if not commit or any(character not in \"0123456789abcdefABCDEF\" for character in commit):\n        raise ValueError(\"committed promotion base is not an immutable object id\")\n    bindings: dict[str, str] = {}\n    for relative, _content in payload:\n        for target in mirror_targets(relative):\n            key = target.as_posix()\n            if key in bindings:\n                raise ValueError(f\"duplicate overlay destination: {target}\")\n            result = run_managed(\n                [\"git\", \"-C\", str(root), \"show\", f\"{commit}:{key}\"],\n                timeout=60,\n                capture_stdout_bytes=MAX_CANDIDATE_OVERLAY_BYTES + 1,\n            )\n            if not result.ok or result.stdout_capture_overflow or result.stdout_capture is None:\n                raise ValueError(f\"committed overlay destination is unavailable: {target}\")\n            bindings[key] = hashlib.sha256(result.stdout_capture).hexdigest()\n    return bindings","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L517-L553","documentation":"Thrown in `committed_destination_base_digests` when `git rev-parse {ref}^{commit}` does not return a usable SHA. The guard requires `rev.ok`, no stdout overflow, and a non-None capture — any failure (bad ref, broken git, oversized output) is treated as 'cannot resolve the immutable base'.","triggerScenarios":"Calling `committed_destination_base_digests(overlay, ref=<ref>)` where `<ref>` does not exist in the repo, the repo has no commits, `git` is not on PATH, the `run_managed` subprocess timed out, or rev-parse printed more than 256 bytes (capture_overflow).","commonSituations":"Passing `ref='origin/main'` before fetching; running on a fresh worktree with detached HEAD pointing at a non-commit; ref was a remote-tracking branch that got pruned; CI checked out a shallow clone missing the ref; the default `ref='HEAD'` on an empty repo.","solutions":["Verify the ref resolves: `git -C <repo> rev-parse '<ref>^{commit}'` in a shell — if it errors, fetch or use a valid ref.","Ensure the repo has at least one commit (not an empty HEAD) and that the ref exists locally, not just on a remote.","Confirm `git` is on PATH and `run_managed` can spawn it (no timeout, exit code 0).","If the ref is a remote, run `git fetch <remote> <ref>` first, or pass `ref='FETCH_HEAD'`."],"exampleFix":"# before\nbases = committed_destination_base_digests(overlay, ref='origin/main')  # ref missing\n# after\nimport subprocess\nsubprocess.run(['git', '-C', str(repo_root), 'fetch', 'origin', 'main'], check=True)\nbases = committed_destination_base_digests(overlay, ref='origin/main')","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef ref_resolves_to_commit(repo_root, ref: str) -> bool:\n    \"\"\"True iff `git rev-parse <ref>^{commit}` exits 0 with a short stdout.\"\"\"\n    try:\n        out = subprocess.run(\n            [\"git\", \"-C\", str(repo_root), \"rev-parse\", f\"{ref}^{{commit}}\"],\n            check=True, capture_output=True, timeout=10,\n        )\n    except (subprocess.CalledProcessError, subprocess.TimeoutExpired):\n        return False\n    return bool(out.stdout.strip())","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Resolve the ref to a SHA in your own code, then pass that SHA as `ref`.","Fetch the remote ref before capturing committed bases (`git fetch <remote> <ref>`).","Never call `committed_destination_base_digests` on an empty repo or an un-fetched remote ref."],"tags":["git","rev-parse","ref-resolution","input-error"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}