usestrix/strix · error · ValueError

Unable to resolve changed files for '{source_path}'. {stderr

Error message

Unable to resolve changed files for '{source_path}'. {stderr or 'Ensure the repository has enough history for diff-scope.'}

What it means

Raised by _resolve_repo_diff_scope (utils.py:996) when `git diff --name-status -z --find-renames --find-copies <merge_base>...HEAD` exits non-zero after a merge-base was successfully computed. The changed-file listing is the core of diff-scope; failure means git could not produce the diff — typically corrupt/missing objects at the boundary, unreadable paths, or index problems. Git's stderr is embedded when available.

Source

Thrown at strix/interface/utils.py:996

            f"Unable to compute merge-base against '{base_ref}' for '{source_path}'. "
            "Ensure the base branch history is fetched and reachable."
        )

    diff_result = _run_git_command_raw(
        repo_path,
        [
            "diff",
            "--name-status",
            "-z",
            "--find-renames",
            "--find-copies",
            f"{merge_base}...HEAD",
        ],
        check=False,
    )
    if diff_result.returncode != 0:
        stderr = diff_result.stderr.decode("utf-8", errors="replace").strip()
        raise ValueError(
            f"Unable to resolve changed files for '{source_path}'. "
            f"{stderr or 'Ensure the repository has enough history for diff-scope.'}"
        )

    entries = _parse_name_status_z(diff_result.stdout)
    classified = _classify_diff_entries(entries)

    return RepoDiffScope(
        source_path=source_path,
        workspace_subdir=workspace_subdir,
        base_ref=base_ref,
        merge_base=merge_base,
        added_files=classified["added_files"],
        modified_files=classified["modified_files"],
        renamed_files=classified["renamed_files"],
        deleted_files=classified["deleted_files"],
        analyzable_files=classified["analyzable_files"],
    )

View on GitHub (pinned to 8551339130)

Solutions

  1. Run git fsck to detect corrupt/missing objects; re-clone if corruption is reported
  2. For partial clones, ensure object fetching works: git rev-list --objects --missing=print HEAD, or use a full clone for diff-scope
  3. Read the embedded {stderr} — it names the exact object/path that failed
  4. git gc / git prune to tidy the object store, then re-run

Example fix

# before
# partial clone, blob fetch blocked offline
strix -t . --diff-scope  # ValueError: Unable to resolve changed files ...

# after
git fetch --refetch origin  # or fresh full clone
git fsck --full
strix -t . --diff-scope --diff-base origin/main
Defensive patterns

Strategy: validation

Validate before calling

r = subprocess.run(["git", "-C", repo, "diff", "--name-status", "-z", f"{merge_base}...HEAD"], capture_output=True)
if r.returncode != 0:
    raise SystemExit("git diff failed; run git fsck and re-clone if objects are missing")

Type guard

def diff_computable(repo: str, merge_base: str) -> bool:
    import subprocess
    return subprocess.run(["git", "-C", repo, "diff", "--name-status", f"{merge_base}...HEAD"], capture_output=True).returncode == 0

Try / catch

try:
    run_diff_scope_scan()
except ValueError as e:
    if "Unable to resolve changed files" in str(e):
        repair_object_store()  # git fsck; git fetch --refetch; re-clone if corrupt
        run_diff_scope_scan()
    else:
        raise

Prevention

When it happens

Trigger: Object store corruption (git fsck errors) between merge-base and HEAD; paths with invalid encoding on the filesystem; a partially-fetched repo where tree/blob objects at the merge-base are missing (partial clone without blob promisor); permission errors reading objects.

Common situations: Partial clones (git clone --filter=blob:none) whose lazy object fetch fails offline; repos with exotic filenames hitting core.quotepath/locale issues; interrupted gc leaving dangling packfiles; network loss during on-demand object fetch in CI.

Related errors


AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15). Data as JSON: /api/errors/1d865329bf1af612. Report an issue: GitHub.