usestrix/strix · error · ValueError

Diff-scope is active, but no local repository targets were p

Error message

Diff-scope is active, but no local repository targets were provided.

What it means

Thrown when diff-scope is active (mode 'diff', or 'auto' that decided to activate) but the local_sources list is empty. Diff-scope needs at least one local Git repository to compute a diff against diff_base; with zero sources there is nothing to diff. The function deliberately refuses to continue rather than silently scanning nothing.

Source

Thrown at strix/interface/utils.py:1046

    if scope_mode == "full":
        return DiffScopeResult(
            active=False,
            mode=scope_mode,
            metadata={"active": False, "mode": scope_mode},
        )

    if scope_mode == "auto":
        should_activate = _should_activate_auto_scope(local_sources, non_interactive, env_map)
        if not should_activate:
            return DiffScopeResult(
                active=False,
                mode=scope_mode,
                metadata={"active": False, "mode": scope_mode},
            )

    if not local_sources:
        raise ValueError("Diff-scope is active, but no local repository targets were provided.")

    repo_scopes: list[RepoDiffScope] = []
    skipped_non_git: list[str] = []
    skipped_diff_scope: list[str] = []
    for source in local_sources:
        source_path = source.get("source_path")
        if not source_path:
            continue
        if not _is_git_repo(Path(source_path)):
            skipped_non_git.append(source_path)
            continue
        try:
            repo_scopes.append(_resolve_repo_diff_scope(source, diff_base, env_map))
        except ValueError as e:
            if scope_mode == "auto":
                skipped_diff_scope.append(f"{source_path} (diff-scope skipped: {e})")
                continue
            raise

View on GitHub (pinned to 8551339130)

Solutions

  1. Pass at least one local source dict with a 'source_path' key pointing at a local Git working copy.
  2. If your targets are remote URLs or cloned repos only, disable diff-scope with --scope-mode full.
  3. If you want automatic behavior with remote targets, use --scope-mode auto so it deactivates instead of raising.

Example fix

# before
result = resolve_diff_scope_context(local_sources=[], scope_mode="diff", diff_base="main", non_interactive=True)

# after
result = resolve_diff_scope_context(
    local_sources=[{"source_path": "/home/me/project"}],
    scope_mode="diff",
    diff_base="main",
    non_interactive=True,
)
Defensive patterns

Strategy: validation

Validate before calling

local_sources = [s for s in local_sources if s.get("source_path")]
if scope_mode == "diff" and not local_sources:
    scope_mode = "full"  # nothing local to diff; scan fully instead
result = resolve_diff_scope_context(local_sources, scope_mode, diff_base, non_interactive)

Type guard

def has_local_source(sources: list[dict]) -> bool:
    return any(isinstance(s.get("source_path"), str) and s["source_path"] for s in sources)

Try / catch

try:
    result = resolve_diff_scope_context(sources, mode, base, non_interactive)
except ValueError as e:
    if "no local repository targets" in str(e):
        result = resolve_diff_scope_context(sources, "full", None, non_interactive)
    else:
        raise

Prevention

When it happens

Trigger: Calling resolve_diff_scope_context(scope_mode='diff', local_sources=[]) — or with sources whose dicts all lack a 'source_path' key; or mode 'auto' in non-interactive runs where _should_activate_auto_scope returned True but no local directory targets were collected (e.g. only a URL or repo target given).

Common situations: Running a scan of a remote URL/repo with --scope-mode diff (diff-scope only works on local code targets); a target-list file that yields only non-local targets; passing local_sources entries built with the wrong dict keys.

Related errors


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