{"record":{"id":"da2059699058134d","repo":"usestrix/strix","slug":"unable-to-compute-merge-base-against-base-ref","errorCode":null,"errorMessage":"Unable to compute merge-base against '{base_ref}' for '{source_path}'. {stderr or 'Ensure the base branch history is fetched and reachable.'}","messagePattern":"Unable to compute merge-base against '(.+?)' for '(.+?)'\\. (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/utils.py","lineNumber":970,"sourceCode":") -> RepoDiffScope:\n    source_path = source.get(\"source_path\", \"\")\n    workspace_subdir = source.get(\"workspace_subdir\")\n    repo_path = Path(source_path)\n\n    if not _is_git_repo(repo_path):\n        raise ValueError(f\"Source is not a git repository: {source_path}\")\n\n    if _is_repo_shallow(repo_path):\n        raise ValueError(\n            \"Strix requires full git history for diff-scope. Please set fetch-depth: 0 \"\n            \"in your CI config.\"\n        )\n\n    base_ref = _resolve_base_ref(repo_path, diff_base, env)\n    merge_base_result = _run_git_command(repo_path, [\"merge-base\", base_ref, \"HEAD\"], check=False)\n    if merge_base_result.returncode != 0:\n        stderr = merge_base_result.stderr.strip()\n        raise ValueError(\n            f\"Unable to compute merge-base against '{base_ref}' for '{source_path}'. \"\n            f\"{stderr or 'Ensure the base branch history is fetched and reachable.'}\"\n        )\n\n    merge_base = merge_base_result.stdout.strip()\n    if not merge_base:\n        raise ValueError(\n            f\"Unable to compute merge-base against '{base_ref}' for '{source_path}'. \"\n            \"Ensure the base branch history is fetched and reachable.\"\n        )\n\n    diff_result = _run_git_command_raw(\n        repo_path,\n        [\n            \"diff\",\n            \"--name-status\",\n            \"-z\",\n            \"--find-renames\",","sourceCodeStart":952,"sourceCodeEnd":988,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/utils.py#L952-L988","documentation":"Raised by _resolve_repo_diff_scope (utils.py:970) when `git merge-base <base_ref> HEAD` exits non-zero. A non-zero merge-base means git could not compute a common ancestor: the base ref does not exist locally, the histories are unrelated, or the shallow boundary cuts the ancestry. The message embeds git's stderr when present, else advises fetching base history.","triggerScenarios":"Passing --diff-base pointing to a ref never fetched (e.g. origin/main when only a feature branch was cloned with --single-branch); unrelated histories (base from a different repo); a base ref that exists but predates a shallow boundary; typo'd ref name.","commonSituations":"CI fetching only the PR merge ref; single-branch clones; forks where origin/main was never fetched; --diff-base main (branch not fetched) instead of origin/main; repositories with grafted/replaced history.","solutions":["Fetch the base explicitly: git fetch origin main, then use --diff-base origin/main","Verify the ref exists: git rev-parse --verify <base>; fix typos (main vs master, missing origin/ prefix)","If histories are genuinely unrelated, pick a base within the same history or drop diff-scope","Ensure the clone is not shallow at the boundary (git fetch --unshallow) so the ancestor is reachable"],"exampleFix":"# before\nstrix -t . --diff-scope --diff-base origin/main  # origin/main never fetched\n# ValueError: Unable to compute merge-base ...\n\n# after\ngit fetch origin main\nstrix -t . --diff-scope --diff-base origin/main","handlingStrategy":"validation","validationCode":"r = subprocess.run([\"git\", \"-C\", repo, \"merge-base\", base_ref, \"HEAD\"], capture_output=True)\nif r.returncode != 0:\n    raise SystemExit(f\"base {base_ref} unreachable; git fetch origin <branch> first\")","typeGuard":"def merge_base_resolvable(repo: str, base_ref: str) -> bool:\n    import subprocess\n    return subprocess.run([\"git\", \"-C\", repo, \"rev-parse\", \"--verify\", base_ref], capture_output=True).returncode == 0","tryCatchPattern":"try:\n    run_diff_scope_scan()\nexcept ValueError as e:\n    if \"Unable to compute merge-base\" in str(e):\n        subprocess.run([\"git\", \"-C\", repo, \"fetch\", \"origin\", default_branch], check=True)\n        run_with_explicit_base(f\"origin/{default_branch}\")\n    else:\n        raise","preventionTips":["Fetch the base branch before running diff-scope","Verify refs with git rev-parse --verify <base> first","Use origin/<branch> names; avoid bare branch names that may not resolve"],"tags":["git","diff-scope","merge-base","ci"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}