{"record":{"id":"93030eb15017fe28","repo":"vercel/turborepo","slug":"affected-could-not-determine-changed-files-all","errorCode":null,"errorMessage":"--affected could not determine changed files. All tasks will run. Check your git fetch depth.","messagePattern":"--affected could not determine changed files\\. All tasks will run\\. Check your git fetch depth\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/turborepo-lib/src/run/builder.rs","lineNumber":1260,"sourceCode":"                    affected_entrypoints.retain(|task| scoped_tasks.contains(task));\n                }\n                let selected_packages = affected_entrypoints\n                    .iter()\n                    .map(|task| PackageName::from(task.package()))\n                    .collect();\n                let affected_entrypoints =\n                    super::task_filter::expand_with_siblings(&engine, affected_entrypoints);\n                Ok((\n                    engine.retain_filtered_tasks(&affected_entrypoints),\n                    Some(selected_packages),\n                ))\n            }\n            Err(e) => {\n                tracing::warn!(\n                    error = ?e,\n                    \"SCM returned invalid change set; skipping task-level filtering\"\n                );\n                turborepo_log::warn(\n                    turborepo_log::Source::turbo(turborepo_log::Subsystem::Scm),\n                    \"--affected could not determine changed files. All tasks will run. Check your \\\n                     git fetch depth.\",\n                )\n                .field(\"error\", format!(\"{e:?}\"))\n                .emit();\n                let Some(package_scope) = package_scope else {\n                    return Ok((engine, None));\n                };\n                let scoped_tasks = engine.task_ids_for_packages(package_scope);\n                let scoped_tasks = super::task_filter::expand_with_siblings(&engine, scoped_tasks);\n                Ok((engine.retain_filtered_tasks(&scoped_tasks), None))\n            }\n        }\n    }\n\n    fn task_entrypoint_exclusions<'a>(\n        &self,","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/vercel/turborepo/blob/f9245100cf0d31d96628804ead485f6bf226e55a/crates/turborepo-lib/src/run/builder.rs#L1242-L1278","documentation":"For `turbo run --affected`, the builder asks the SCM layer (git) for the set of changed files relative to the base. If git reports an invalid/failed change set (crates/turborepo-lib/src/run/builder.rs:1251-1271), turbo cannot know which tasks are affected, warns, and degrades gracefully: with a package scope it keeps that scope; otherwise every task in the graph runs.","triggerScenarios":"git fails to compute changed files: shallow clones where the merge-base commit is missing (typical CI checkout with fetch-depth: 1), a missing/incorrect default branch (origin/HEAD unset or base branch not fetched), or a corrupt git index. The raw error is attached as a structured 'error' field next to the warning.","commonSituations":"GitHub Actions actions/checkout with default depth 1, GitLab shallow clones, CI checkouts that never fetch the target branch, and monorepos after force-pushes where the expected merge-base doesn't exist locally. Symptom: --affected always runs everything.","solutions":["Deepen history so the merge-base exists: git fetch --unshallow (or git fetch --deepen=100 / --depth=N large enough) before turbo run --affected.","Make sure the default/base branch is fetched and origin/HEAD resolves: git remote set-head origin --auto; fetch the base branch explicitly.","Sanity-check locally: `git merge-base HEAD origin/<default-branch>` must print a commit, not fail.","In CI, set the base explicitly (e.g. --affected vs the configured base/SCM options) or use a full clone for affected runs."],"exampleFix":"# before: shallow checkout, affected can never resolve\n- uses: actions/checkout@v4        # depth: 1 by default\n- run: pnpm turbo run build --affected\n\n# after: fetch enough history for the merge base\n- uses: actions/checkout@v4\n  with:\n    fetch-depth: 0        # or a deep enough number\n- run: pnpm turbo run build --affected","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# --affected requires a resolvable merge base\nDEFAULT_BRANCH=\"${DEFAULT_BRANCH:-origin/main}\"\ngit fetch --deepen=200 \"$DEFAULT_BRANCH\" 2>/dev/null || git fetch --unshallow\nif ! git merge-base HEAD \"$DEFAULT_BRANCH\" >/dev/null 2>&1; then\n  echo \"merge base with $DEFAULT_BRANCH unavailable — --affected would run all tasks\" >&2\n  exit 1\nfi\nturbo run build --affected","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use fetch-depth: 0 (or a sufficiently deep fetch) in CI checkouts that run --affected.","Ensure origin/HEAD points at the real default branch (git remote set-head origin --auto).","Smoke-test `git merge-base HEAD origin/<default>` locally before relying on --affected in pipelines."],"tags":["turborepo","affected","git","shallow-clone","ci","scm"],"backgroundTag":"shallow-clone-merge-base-missing","analyzedSha":"f9245100cf0d31d96628804ead485f6bf226e55a","analyzedAt":"2026-08-17T10:46:15.696Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}