{"record":{"id":"644de9b9f8f9bc7a","repo":"usestrix/strix","slug":"strix-requires-full-git-history-for-diff-scope-pl","errorCode":null,"errorMessage":"Strix requires full git history for diff-scope. Please set fetch-depth: 0 in your CI config.","messagePattern":"Strix requires full git history for diff-scope\\. Please set fetch-depth: 0 in your CI config\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/utils.py","lineNumber":961,"sourceCode":"        current_branch = _get_current_branch_name(repo_path)\n        default_branch = _resolve_default_branch_name(repo_path, env)\n        if current_branch and default_branch and current_branch != default_branch:\n            return True\n    return False\n\n\ndef _resolve_repo_diff_scope(\n    source: dict[str, str], diff_base: str | None, env: dict[str, str]\n) -> 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.\"","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/utils.py#L943-L979","documentation":"Raised by _resolve_repo_diff_scope (utils.py:961) when the repo is a git repository but _is_repo_shallow reports it was cloned with --depth (a .git/shallow file exists). Diff-scope computes merge-base against the base ref, which requires the full history; a shallow clone can make the base unreachable and produce wrong or empty diffs, so Strix refuses upfront.","triggerScenarios":"Diff-scope on a repo cloned with git clone --depth=1 or --single-branch; GitHub Actions actions/checkout with default fetch-depth: 1; Docker builds using shallow clones; minimal CI images that default to shallow fetch.","commonSituations":"actions/checkout@v4 without fetch-depth: 0; GitLab CI default shallow clone (GIT_DEPTH=1); space-saving shallow clones in CI caches; developers reusing CI-built shallow workspaces locally.","solutions":["In GitHub Actions set 'fetch-depth: 0' on the checkout step (the error message names this exact fix)","Unshallow an existing clone: git fetch --unshallow (or git fetch --depth=<large>) then re-run","For GitLab, set GIT_DEPTH: 0 in CI variables","Clone fresh without --depth for diff-scope runs"],"exampleFix":"# before\n- uses: actions/checkout@v4   # fetch-depth: 1 (shallow)\n- run: strix -t . --diff-scope\n\n# after\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 0\n- run: strix -t . --diff-scope --diff-base origin/main","handlingStrategy":"validation","validationCode":"if (Path(source_path) / \".git\" / \"shallow\").exists():\n    raise SystemExit(\"shallow clone detected; run `git fetch --unshallow` before diff-scope\")","typeGuard":"def is_full_clone(path: str) -> bool:\n    return not (Path(path) / \".git\" / \"shallow\").exists()","tryCatchPattern":"try:\n    run_diff_scope_scan()\nexcept ValueError as e:\n    if \"full git history\" in str(e):\n        subprocess.run([\"git\", \"-C\", source_path, \"fetch\", \"--unshallow\"], check=True)\n        run_diff_scope_scan()  # retry once unshallowed\n    else:\n        raise","preventionTips":["Set fetch-depth: 0 in actions/checkout for diff-scope jobs","Set GIT_DEPTH: 0 in GitLab CI","Never clone with --depth for diff-scope pipelines"],"tags":["git","diff-scope","ci","shallow-clone"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}