{"record":{"id":"6bf9877f9fef6485","repo":"abhigyanpatwari/GitNexus","slug":"ref-ref-r-not-found-in-clone-of-repo","errorCode":null,"errorMessage":"ref {ref!r} not found in clone of {repo}","messagePattern":"ref (.+?) not found in clone of (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/runner_artifacts.py","lineNumber":332,"sourceCode":"                str(repo),\n                str(target),\n            ],\n            timeout=600,\n        )\n        alternates = target / \".git\" / \"objects\" / \"info\" / \"alternates\"\n        if alternates.exists():\n            raise RuntimeError(f\"clone unexpectedly has an external object alternate: {alternates}\")\n        for obj in (target / \".git\" / \"objects\").rglob(\"*\"):\n            if obj.is_file() and obj.stat().st_nlink > 1:\n                raise RuntimeError(f\"clone object is hardlinked to host storage: {obj}\")\n        for candidate in (ref, f\"origin/{ref}\"):\n            proc = run_managed(\n                [\"git\", \"-C\", str(target), \"checkout\", \"--detach\", \"--quiet\", candidate],\n                timeout=60,\n            )\n            if proc.ok:\n                return target\n        raise RuntimeError(f\"ref {ref!r} not found in clone of {repo}\")\n    except BaseException as primary:\n        if target.exists():\n            try:\n                shutil.rmtree(target)\n            except OSError as cleanup:\n                primary.add_note(f\"clone cleanup also failed: {type(cleanup).__name__}: {cleanup}\")\n        raise\n\n\ndef remove_clone(clone: Path) -> None:\n    \"\"\"Delete one throwaway arm clone (created by make_worktree).\"\"\"\n\n    shutil.rmtree(clone)\n\n\ndef parse_shortstat(text: str) -> dict[str, int]:\n    \"\"\"Parse `git diff --shortstat` output into churn counters.\"\"\"\n","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/runner_artifacts.py#L314-L350","documentation":"Thrown by make_worktree after it tries `git checkout --detach` for both the bare ref and the origin/-prefixed ref. If neither checkout succeeds, the requested ref does not exist in the freshly cloned repository, so the arm cannot start from the intended baseline.","triggerScenarios":"For candidate in [ref, f'origin/{ref}'], `run_managed([... 'checkout','--detach', candidate]).ok` is False for both. The ref was not fetched, was misspelled, or only exists as a remote-tracking ref under a different name.","commonSituations":"The task config's `ref` field points to a branch/tag that does not exist on the source remote; `--no-tags` stripped a tag-only ref; the ref is local to a fork not configured as origin; typo in the ref name; shallow/partial clone excluded the ref.","solutions":["Verify the ref exists on the source: `git ls-remote --heads --tags <repo> | grep <ref>`.","Correct the `ref` field in the task definition to an existing branch or tag (or its full refs/heads/... / refs/tags/... form).","If the ref is a tag, note the harness clones with --no-tags; fetch it explicitly or use a branch ref.","Ensure the clone is not shallow/partial for the ref you need."],"exampleFix":"// before — task ref points at a non-existent branch\n{\"id\": \"t1\", \"repo\": \"...\", \"ref\": \"feature/old-name\", ...}\n\n// after — use a ref that exists on the remote\n{\"id\": \"t1\", \"repo\": \"...\", \"ref\": \"main\", ...}","handlingStrategy":"validation","validationCode":"import subprocess\n\ndef ref_exists(repo: str, ref: str) -> bool:\n    out = subprocess.run(['git', 'ls-remote', '--heads', '--tags', repo],\n                         capture_output=True, text=True)\n    refs = {line.split()[-1] for line in out.stdout.splitlines()}\n    return f'refs/heads/{ref}' in refs or f'refs/tags/{ref}' in refs or ref in refs","typeGuard":"null","tryCatchPattern":"try:\n    make_worktree(repo, ref, parent)\nexcept RuntimeError as e:\n    if 'not found in clone' in str(e):\n        print('ref missing on remote; pick an existing branch/tag')\n        raise\n    raise","preventionTips":["Validate task `ref` against `git ls-remote` before submitting the task.","Remember the harness clones with --no-tags; prefer branch refs over tags.","Use full refs/heads/<name> when ambiguity is possible.","Confirm the remote configured as `repo` actually has the ref."],"tags":["git-clone","ref-resolution","task-config","workflow-bench"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}