Skip to content

fix: Prevent filterUsingTasks --filter from pulling dependents into Task Graph#12535

Merged
anthonyshew merged 2 commits intomainfrom
shew/fix-filter-tasks
Apr 2, 2026
Merged

fix: Prevent filterUsingTasks --filter from pulling dependents into Task Graph#12535
anthonyshew merged 2 commits intomainfrom
shew/fix-filter-tasks

Conversation

@anthonyshew
Copy link
Copy Markdown
Contributor

Summary

  • --filter ./packages/* with filterUsingTasks enabled was incorrectly including apps in the task graph
  • filter_engine_to_tasks() was calling retain_affected_tasks() which does a reverse DFS (finding dependents) before a forward DFS (finding dependencies) — correct for --affected, wrong for --filter
  • Added Engine::retain_filtered_tasks() that does forward DFS only (transitive dependencies for execution, no dependent expansion)

Why

When a user writes --filter ./packages/*, they expect only tasks from packages/* to run. The ... dependent/dependency expansion is handled during selector resolution — the final pruning step should only add upstream dependencies needed for execution, not pull in downstream consumers.

How to test

cargo test -p turborepo-lib -- task_filter — includes a regression test (filter_does_not_include_dependents) that sets up app#build -> ui#build and asserts filtering to ui does not pull in app.

…lterUsingTasks

filter_engine_to_tasks() was calling retain_affected_tasks() which does
a reverse DFS (finding dependents) before a forward DFS (finding
dependencies). This caused --filter ./packages/* to include apps that
depend on those packages.

Add retain_filtered_tasks() that does forward DFS only, and use it in
the --filter codepath. Dependent expansion is already handled during
selector resolution via include_dependents.
@anthonyshew anthonyshew requested a review from a team as a code owner April 2, 2026 13:33
@anthonyshew anthonyshew requested review from tknickman and removed request for a team April 2, 2026 13:33
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
examples-basic-web Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-designsystem-docs Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-gatsby-web Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-kitchensink-blog Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-nonmonorepo Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-svelte-web Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-tailwind-web Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
examples-vite-web Building Building Preview, Open in v0 Apr 2, 2026 1:34pm
turbo-site Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm
turborepo-agents Ready Ready Preview, Comment, Open in v0 Apr 2, 2026 1:34pm

@anthonyshew anthonyshew changed the title fix: Prevent filterUsingTasks --filter from pulling dependents into task graph fix: Prevent filterUsingTasks --filter from pulling dependents into Task Graph Apr 2, 2026
@anthonyshew anthonyshew merged commit d3aca27 into main Apr 2, 2026
59 checks passed
@anthonyshew anthonyshew deleted the shew/fix-filter-tasks branch April 2, 2026 13:47
github-actions Bot added a commit that referenced this pull request Apr 2, 2026
## Release v2.9.4-canary.3

Versioned docs: https://v2-9-4-canary-3.turborepo.dev

### Changes

- release(turborepo): 2.9.4-canary.2 (#12533) (`d2944c4`)
- docs: Send siteId as label on feedback GitHub issues (#12527)
(`6644f34`)
- Replace local ai-agent-detection with @vercel/agent-readability
(#12528) (`86d34cc`)
- fix: Prevent `filterUsingTasks` `--filter` from pulling dependents
into Task Graph (#12535) (`d3aca27`)

Co-authored-by: Turbobot <turbobot@vercel.com>
github-actions Bot added a commit that referenced this pull request Apr 5, 2026
## Release v2.9.4

Versioned docs: https://v2-9-4.turborepo.dev

### Changes

- release(turborepo): 2.9.3 (#12524) (`0b48404`)
- fix: Always update $schema URL to versioned format during migration
(#12529) (`389cd5e`)
- release(turborepo): 2.9.4-canary.1 (#12530) (`7f8cb9a`)
- fix: Support `turbo.jsonc` in codemod transforms (#12532) (`e570d29`)
- feat: Add incremental task caching (#12531) (`39c4934`)
- release(turborepo): 2.9.4-canary.2 (#12533) (`d2944c4`)
- docs: Send siteId as label on feedback GitHub issues (#12527)
(`6644f34`)
- Replace local ai-agent-detection with @vercel/agent-readability
(#12528) (`86d34cc`)
- fix: Prevent `filterUsingTasks` `--filter` from pulling dependents
into Task Graph (#12535) (`d3aca27`)
- release(turborepo): 2.9.4-canary.3 (#12536) (`074a0ef`)
- build(deps): Bump @xmldom/xmldom from 0.8.11 to 0.8.12 in
/examples/with-react-native-web (#12537) (`295a89b`)
- fix: Only enforce signature key length for keys that exist (#12538)
(`27ac52f`)
- release(turborepo): 2.9.4-canary.4 (#12539) (`f745fc7`)
- fix: Validate engine concurrency after task-level filtering (#12540)
(`a38658a`)
- release(turborepo): 2.9.4-canary.5 (#12541) (`ac99fac`)
- fix: Preserve prerelease info in schema URL during codemod migration
(#12542) (`81b39a5`)
- feat: Allow `--affected` and `--filter` to be combined (#12543)
(`98ab3b6`)
- fix(config): Deep-merge nested OTEL config across priority sources
(#12513) (`f214dc8`)
- release(turborepo): 2.9.4-canary.6 (#12544) (`0e763f8`)
- fix: Retain microfrontend proxy tasks when using `filterUsingTasks`
(#12545) (`a4b943e`)
- release(turborepo): 2.9.4-canary.7 (#12546) (`b7d89a4`)
- fix: Bun workspace lockfile pruning producing invalid output (#12548)
(`0346076`)
- fix: Respect dirty .gitignore patterns during task input hashing
(#12557) (`1254916`)
- release(turborepo): 2.9.4-canary.8 (#12558) (`01802b4`)

---------

Co-authored-by: Turbobot <turbobot@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant