{"record":{"id":"d979c6ae26a94350","repo":"zed-industries/zed","slug":"origin-main-tip-main-sha-12-unavailable-locall","errorCode":null,"errorMessage":"origin/main tip {main_sha[:12]} unavailable locally after fetch","messagePattern":"origin/main tip (.+?) unavailable locally after fetch","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"crates/eval_cli/zed_eval/source.py","lineNumber":107,"sourceCode":"def base_sha_on_main(base_sha: str, repo_url: str) -> bool:\n    \"\"\"Whether `base_sha` is reachable from origin/main.\n\n    Resolves origin/main's tip against the remote (so it doesn't depend on the\n    caller's possibly-stale local refs), fetching main if the objects aren't\n    present locally, then checks ancestry. Raises only when the main tip can't be\n    made available locally (a network/remote problem), so callers can\n    distinguish that from a definitive \"not on main\".\n    \"\"\"\n    main_sha = resolve_remote_ref(repo_url, \"main\")\n    if base_sha.lower() == main_sha.lower():\n        return True\n    if not (commit_present(base_sha) and commit_present(main_sha)):\n        subprocess.run(\n            [\"git\", \"-C\", repo_root(), \"fetch\", \"--quiet\", repo_url, \"main\"],\n            capture_output=True,\n        )\n    if not commit_present(main_sha):\n        raise RuntimeError(\n            f\"origin/main tip {main_sha[:12]} unavailable locally after fetch\"\n        )\n    if not commit_present(base_sha):\n        # Not present even after pulling main's history -> not reachable from main.\n        return False\n    ancestry = subprocess.run(\n        [\"git\", \"-C\", repo_root(), \"merge-base\", \"--is-ancestor\", base_sha, main_sha],\n        capture_output=True,\n    )\n    if ancestry.returncode in (0, 1):\n        return ancestry.returncode == 0\n    raise RuntimeError(\n        (ancestry.stderr or b\"\").decode(errors=\"replace\").strip()\n        or \"git merge-base --is-ancestor failed\"\n    )\n\n\ndef resolve_git_ref(ref: str) -> str:","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/zed_eval/source.py#L89-L125","documentation":"The on-main check resolves origin/main's tip sha via ls-remote, then fetches main into the local repo to test ancestry. If after `git fetch <repo_url> main` the resolved main sha still is not present locally, this RuntimeError fires. The fetch's output is captured and swallowed, so the real network, auth, or ref problem is hidden; the docstring frames this as 'cannot answer' rather than a definitive 'not on main'.","triggerScenarios":"The machine is offline or DNS fails so the fetch silently errors; repo_url requires credentials that are missing or expired; main was force-pushed between resolve_remote_ref and fetch so the old tip is no longer served; the local clone is shallow or partial with fetch restrictions.","commonSituations":"CI runner without egress to the git host; expired PAT or SSH key; races during active pushes to main; corporate proxies blocking git; filtered partial clones.","solutions":["Run the fetch manually to surface the real error: git -C <repo> fetch <repo_url> main","Fix network or credentials for the git host, then retry","Re-resolve origin/main before retrying — if main moved, recompute main_sha with resolve_remote_ref","If the local repo is shallow/partial, unshallow it or work from a full clone"],"exampleFix":"# before\non_main = check_on_main(...)  # RuntimeError: origin/main tip 0123456789ab unavailable locally after fetch\n\n# after — expose the swallowed fetch error\ngit -C $ZED_EVAL_REPO fetch <repo_url> main   # fix auth/network, then retry","handlingStrategy":"retry","validationCode":"completed = subprocess.run(\n    [\"git\", \"-C\", repo_root(), \"fetch\", repo_url, \"main\"], capture_output=True\n)\nif completed.returncode != 0:\n    raise RuntimeError(completed.stderr.decode(errors=\"replace\"))  # surface before the ancestry check","typeGuard":null,"tryCatchPattern":"try:\n    on_main = check_on_main(base_sha, repo_url)\nexcept RuntimeError as err:\n    if \"unavailable locally after fetch\" in str(err):\n        wait_for_connectivity()  # re-resolve origin/main too, in case it moved\n        on_main = check_on_main(base_sha, repo_url)\n    else:\n        raise","preventionTips":["Keep git host credentials current in CI","When this fires, run the manual fetch command — the real error was captured and hidden","Re-resolve origin/main before retrying to avoid sha races during active pushes"],"tags":["git","fetch","network","auth","remote"],"backgroundTag":"git-fetch-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}