usestrix/strix · error · ValueError

Source is not a git repository: {source_path}

Error message

Source is not a git repository: {source_path}

What it means

Raised by _resolve_repo_diff_scope (utils.py:958) when diff-scope is requested but the source_path in the source descriptor is not inside a git working tree (the .git directory / worktree check via _is_git_repo fails). Strix needs git history to compute the merge-base and changed-file set, so a plain directory cannot be diff-scoped.

Source

Thrown at strix/interface/utils.py:958

        repo_path = Path(source_path)
        if not _is_git_repo(repo_path):
            continue
        current_branch = _get_current_branch_name(repo_path)
        default_branch = _resolve_default_branch_name(repo_path, env)
        if current_branch and default_branch and current_branch != default_branch:
            return True
    return False


def _resolve_repo_diff_scope(
    source: dict[str, str], diff_base: str | None, env: dict[str, str]
) -> RepoDiffScope:
    source_path = source.get("source_path", "")
    workspace_subdir = source.get("workspace_subdir")
    repo_path = Path(source_path)

    if not _is_git_repo(repo_path):
        raise ValueError(f"Source is not a git repository: {source_path}")

    if _is_repo_shallow(repo_path):
        raise ValueError(
            "Strix requires full git history for diff-scope. Please set fetch-depth: 0 "
            "in your CI config."
        )

    base_ref = _resolve_base_ref(repo_path, diff_base, env)
    merge_base_result = _run_git_command(repo_path, ["merge-base", base_ref, "HEAD"], check=False)
    if merge_base_result.returncode != 0:
        stderr = merge_base_result.stderr.strip()
        raise ValueError(
            f"Unable to compute merge-base against '{base_ref}' for '{source_path}'. "
            f"{stderr or 'Ensure the base branch history is fetched and reachable.'}"
        )

    merge_base = merge_base_result.stdout.strip()
    if not merge_base:

View on GitHub (pinned to 8551339130)

Solutions

  1. Run against a real git clone: git clone <url> && strix -t ./repo --diff-scope
  2. If .git is a gitfile (worktree/submodule), fix the absolute path inside it after moving the checkout
  3. Drop --diff-scope for non-repo directories and scan the full tree instead
  4. In CI, check out with git (actions/checkout) rather than exporting archives

Example fix

# before
curl -L https://github.com/org/repo/archive/main.tar.gz | tar xz
strix -t ./repo-main --diff-scope  # not a git repository

# after
git clone --depth 0 https://github.com/org/repo.git
strix -t ./repo --diff-base origin/main
Defensive patterns

Strategy: validation

Validate before calling

import subprocess
rc = subprocess.run(["git", "-C", source_path, "rev-parse", "--is-inside-work-tree"], capture_output=True)
if rc.returncode != 0:
    raise SystemExit(f"{source_path} is not a git clone; clone it or drop --diff-scope")

Type guard

def is_git_worktree(path: str) -> bool:
    import subprocess
    r = subprocess.run(["git", "-C", path, "rev-parse", "--is-inside-work-tree"], capture_output=True)
    return r.returncode == 0 and r.stdout.strip() == b"true"

Try / catch

try:
    run_diff_scope_scan()
except ValueError as e:
    if "not a git repository" in str(e):
        reclone_or_scan_full_tree()  # git clone the source, or omit --diff-scope
    else:
        raise

Prevention

When it happens

Trigger: Passing a directory that was exported, copied without .git, tar-extracted, or mounted read-only; source_path pointing to a subdirectory of a repo checkout where .git detection fails (e.g. .git is a broken gitfile); running against /tmp scratch copies.

Common situations: CI jobs that rsync or unzip source before scanning; Docker COPY of the working tree without .git; downloading a source tarball from GitHub; a repo cloned then moved breaking the .git gitfile's absolute path.

Related errors


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