{"record":{"id":"c65653e10aa0e646","repo":"usestrix/strix","slug":"diff-scope-is-active-but-no-git-repositories-were","errorCode":null,"errorMessage":"Diff-scope is active, but no Git repositories were found. Use --scope-mode full to disable diff-scope for this run.","messagePattern":"Diff-scope is active, but no Git repositories were found\\. Use --scope-mode full to disable diff-scope for this run\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"strix/interface/utils.py","lineNumber":1075,"sourceCode":"            continue\n        try:\n            repo_scopes.append(_resolve_repo_diff_scope(source, diff_base, env_map))\n        except ValueError as e:\n            if scope_mode == \"auto\":\n                skipped_diff_scope.append(f\"{source_path} (diff-scope skipped: {e})\")\n                continue\n            raise\n\n    if not repo_scopes:\n        if scope_mode == \"auto\":\n            metadata: dict[str, Any] = {\"active\": False, \"mode\": scope_mode}\n            if skipped_non_git:\n                metadata[\"skipped_non_git_sources\"] = skipped_non_git\n            if skipped_diff_scope:\n                metadata[\"skipped_diff_scope_sources\"] = skipped_diff_scope\n            return DiffScopeResult(active=False, mode=scope_mode, metadata=metadata)\n\n        raise ValueError(\n            \"Diff-scope is active, but no Git repositories were found. \"\n            \"Use --scope-mode full to disable diff-scope for this run.\"\n        )\n\n    instruction_block = build_diff_scope_instruction(repo_scopes)\n    metadata = {\n        \"active\": True,\n        \"mode\": scope_mode,\n        \"repos\": [scope.to_metadata() for scope in repo_scopes],\n        \"total_repositories\": len(repo_scopes),\n        \"total_analyzable_files\": sum(len(scope.analyzable_files) for scope in repo_scopes),\n        \"total_deleted_files\": sum(len(scope.deleted_files) for scope in repo_scopes),\n    }\n    if skipped_non_git:\n        metadata[\"skipped_non_git_sources\"] = skipped_non_git\n    if skipped_diff_scope:\n        metadata[\"skipped_diff_scope_sources\"] = skipped_diff_scope\n","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/usestrix/strix/blob/85513391305171ecc6faffe03da4a8bda5e3febb/strix/interface/utils.py#L1057-L1093","documentation":"Thrown when diff-scope is explicitly requested (mode 'diff') but none of the provided local sources produced a RepoDiffScope — every source was skipped because it was not a Git repository, or repo-level diff computation failed. In 'auto' mode the same situation returns inactive instead of raising; only explicit 'diff' mode errors. The message points at --scope-mode full as the escape hatch.","triggerScenarios":"scope_mode='diff' with local_sources whose paths are all non-Git directories (skipped_non_git populated), or whose git diff computation against diff_base raised/produced nothing (skipped_diff_scope populated) so repo_scopes stays empty.","commonSituations":"Pointing the scan at a folder that was copied out of Git (no .git directory); using a diff_base that does not exist in any of the repos (e.g. default branch name mismatch like main vs master); nested worktrees or submodules the check cannot handle.","solutions":["Run with --scope-mode full if you do not actually need diff-limited scanning.","Verify each target directory is a Git repo: ls <path>/.git (or git -C <path> status).","Check that diff_base names a ref that exists in every target repo (git -C <path> rev-parse --verify <diff_base>).","Use --scope-mode auto so non-Git sources cause graceful deactivation with metadata instead of an error."],"exampleFix":"# CLI - before\nstrix -n -t ./my-folder --scope-mode diff --diff-base main\n\n# CLI - after (folder is not a git repo)\nstrix -n -t ./my-folder --scope-mode full","handlingStrategy":"fallback","validationCode":"import subprocess\n\ndef all_targets_are_git(paths: list[str], diff_base: str) -> bool:\n    for p in paths:\n        try:\n            subprocess.run([\"git\", \"-C\", p, \"rev-parse\", \"--verify\", diff_base],\n                           check=True, capture_output=True)\n        except subprocess.CalledProcessError:\n            return False\n    return True\n\nif scope_mode == \"diff\" and not all_targets_are_git(paths, diff_base or \"main\"):\n    scope_mode = \"full\"","typeGuard":"from pathlib import Path\n\ndef is_git_working_copy(path: str) -> bool:\n    return (Path(path) / \".git\").exists()","tryCatchPattern":"try:\n    result = resolve_diff_scope_context(sources, \"diff\", base, non_interactive)\nexcept ValueError as e:\n    if \"no Git repositories were found\" in str(e):\n        result = resolve_diff_scope_context(sources, \"full\", None, non_interactive)\n    else:\n        raise","preventionTips":["Prefer --scope-mode auto unless diff-scope is mandatory for the workflow","Confirm each target has a .git dir and the diff_base ref exists before the run","Check result.metadata['skipped_non_git_sources'] / ['skipped_diff_scope_sources'] in auto mode to see why repos were skipped"],"tags":["diff-scope","git","validation","targets"],"backgroundTag":null,"analyzedSha":"85513391305171ecc6faffe03da4a8bda5e3febb","analyzedAt":"2026-08-15T05:03:57.275Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}