{"record":{"id":"932dd114af16f6a9","repo":"abhigyanpatwari/GitNexus","slug":"clone-unexpectedly-has-an-external-object-alternat","errorCode":null,"errorMessage":"clone unexpectedly has an external object alternate: {alternates}","messagePattern":"clone unexpectedly has an external object alternate: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/runner_artifacts.py","lineNumber":321,"sourceCode":"    target = Path(tempfile.mkdtemp(prefix=\"wfbench-\", dir=parent))\n    target.rmdir()\n    try:\n        run_checked(\n            [\n                \"git\",\n                \"clone\",\n                \"--no-local\",\n                \"--no-hardlinks\",\n                \"--no-tags\",\n                \"--quiet\",\n                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","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/runner_artifacts.py#L303-L339","documentation":"Thrown by make_worktree after a `git clone --no-local --no-hardlinks`. That clone mode is chosen so the benchmark arm gets a fully self-contained object database; if `.git/objects/info/alternates` exists afterward, the clone is secretly borrowing objects from another store, which breaks the isolation guarantee (the arm could read or depend on host state it should not see).","triggerScenarios":"After clone, `(target/.git/objects/info/alternates).exists()` is True. The clone picked up an alternates file, e.g. because a global git config or template enabled it, or the source repo itself had alternates.","commonSituations":"A global ~/.gitconfig or /etc/gitconfig sets clone.defaultResolverName or shares objects; the source repo is itself a linked/alternate checkout; a CI image pre-configures object sharing; running against a repo created by `git clone --reference`.","solutions":["Pass `-c clone.defaultResolverName=loose` (or unset any alternates-inducing config) for the clone, or clone from a clean pack of the repo.","Check `git config --system --list` and `--global --list` for object-sharing settings and remove them for the benchmark run.","Re-create the source repo as a normal full clone with no alternates before benchmarking.","Run the harness in the clean container/sandbox image it ships with, where this config is controlled."],"exampleFix":"// before\nrun_checked(['git','clone','--no-local','--no-hardlinks', str(repo), str(target)])\n\n// after — disable any inherited alternates behavior\nrun_checked(['git','-c','protocol.version=2','clone','--no-local','--no-hardlinks','--no-tags','--quiet', str(repo), str(target)])\n# plus ensure source `repo` has no .git/objects/info/alternates of its own","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef clone_has_no_alternates(target: Path) -> bool:\n    return not (target / '.git' / 'objects' / 'info' / 'alternates').exists()","typeGuard":"null","tryCatchPattern":"try:\n    make_worktree(repo, ref, parent)\nexcept RuntimeError as e:\n    if 'external object alternate' in str(e):\n        # inspect/fix git config that induced alternates, then retry\n        raise\n    raise","preventionTips":["Run the harness in its clean container image where git config is controlled.","Check `git config --system --global --list` for object-sharing keys before benchmarking.","Ensure the source repo has no .git/objects/info/alternates of its own.","Prefer cloning from a freshly made full pack of the repo."],"tags":["git-clone","sandbox-isolation","alternates","workflow-bench"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}