From 46062886c7dcbdb795cb328013f372d17a752a30 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 06:35:04 +0000 Subject: [PATCH 1/2] test(run): record a missing task failing on an unreached package config `vt run ship` in a package that doesn't define `ship` falls back to listing every task, which loads every package's config. When a package the run never reaches has a broken config, the run fails with that config's error instead of `Task "ship" not found`. `vt run --parallel ship`, which skips the fallback, reports the task as not found. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01978g7XjjyssC8wfgdfpPwe --- .../lazy_config_task_not_found/package.json | 4 ++ .../packages/app/package.json | 6 +++ .../packages/broken/package.json | 6 +++ .../packages/broken/vite-task.json | 3 ++ .../pnpm-workspace.yaml | 2 + .../lazy_config_task_not_found/snapshots.toml | 32 ++++++++++++++ ...ssing_task_with_unreached_broken_config.md | 43 +++++++++++++++++++ 7 files changed, 96 insertions(+) create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/package.json create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/app/package.json create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/package.json create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/vite-task.json create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/pnpm-workspace.yaml create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml create mode 100644 crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/package.json b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/package.json new file mode 100644 index 000000000..06ec03a51 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/package.json @@ -0,0 +1,4 @@ +{ + "name": "lazy-config-task-not-found", + "private": true +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/app/package.json b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/app/package.json new file mode 100644 index 000000000..b2499ff82 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/app/package.json @@ -0,0 +1,6 @@ +{ + "name": "@test/app", + "scripts": { + "build": "echo 'Building app'" + } +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/package.json b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/package.json new file mode 100644 index 000000000..48a1d059a --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/package.json @@ -0,0 +1,6 @@ +{ + "name": "@test/broken", + "scripts": { + "build": "echo 'Building broken'" + } +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/vite-task.json b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/vite-task.json new file mode 100644 index 000000000..d548edfac --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/packages/broken/vite-task.json @@ -0,0 +1,3 @@ +{ + "cache": true +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/pnpm-workspace.yaml b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/pnpm-workspace.yaml new file mode 100644 index 000000000..924b55f42 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - packages/* diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml new file mode 100644 index 000000000..504d5bf1e --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml @@ -0,0 +1,32 @@ +[[e2e]] +name = "missing_task_with_unreached_broken_config" +comment = """ +`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. Neither should `vt run ship`, a task `@test/app` doesn't define, but it falls back to listing every task, so it fails with `@test/broken`'s error instead of saying `Task "ship" not found`. With `--parallel`, which skips that fallback, the same command gets the not-found error. +""" +cwd = "packages/app" +steps = [ + { argv = [ + "vt", + "run", + "build", + ], comment = "never reads @test/broken's config" }, + { argv = [ + "vtt", + "pipe-stdout", + "--", + "vt", + "run", + "ship", + ], comment = "fails with @test/broken's error instead of `Task \"ship\" not found.`" }, + { argv = [ + "vt", + "run", + "ship", + ], comment = "in a terminal, fails with the same error" }, + { argv = [ + "vt", + "run", + "--parallel", + "ship", + ], comment = "without the fallback, the same command is reported as not found" }, +] diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md new file mode 100644 index 000000000..6831e373d --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md @@ -0,0 +1,43 @@ +# missing_task_with_unreached_broken_config + +`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. Neither should `vt run ship`, a task `@test/app` doesn't define, but it falls back to listing every task, so it fails with `@test/broken`'s error instead of saying `Task "ship" not found`. With `--parallel`, which skips that fallback, the same command gets the not-found error. + +## `vt run build` + +never reads @test/broken's config + +``` +~/packages/app$ echo 'Building app' ⊘ cache disabled +Building app +``` + +## `vtt pipe-stdout -- vt run ship` + +fails with @test/broken's error instead of `Task "ship" not found.` + +**Exit code:** 1 + +``` +error: `cache` can only be set in the workspace root config, but found in /packages/broken +--- stdout --- +``` + +## `vt run ship` + +in a terminal, fails with the same error + +**Exit code:** 1 + +``` +error: `cache` can only be set in the workspace root config, but found in /packages/broken +``` + +## `vt run --parallel ship` + +without the fallback, the same command is reported as not found + +**Exit code:** 1 + +``` +error: Task "ship" not found +``` From b799ca8be3d172572340b38f398e868c020c1c3b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Nov 2026 06:38:46 +0000 Subject: [PATCH 2/2] fix(run): report a missing task as not found when another config fails to load `vp run ` in a package that doesn't define the task falls back to the task selector, or to the task list when output isn't a terminal. Listing loads every package's config, so a broken config in a package the run never reaches failed the run with that package's error. Now the run reports `Task "" not found`, as it does when the fallback is skipped. `vp run` without a task still fails with the config's error. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01978g7XjjyssC8wfgdfpPwe --- CHANGELOG.md | 1 + crates/vt/src/session/mod.rs | 14 +++++++++++++- .../lazy_config_task_not_found/snapshots.toml | 8 ++++---- .../missing_task_with_unreached_broken_config.md | 12 ++++++------ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 267b050f7..761142744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- **Fixed** `vp run ` in a package that doesn't define the task now reports `Task "" not found` when another package's `vite.config.*` fails to load, instead of failing with that package's error. Showing the tasks to choose from loads every package's config, so the task selector or task list is skipped then ([#987](https://github.com/voidzero-dev/vite-task/pull/987)). - **Fixed** A task specifier like `vp run nope#build`, where no workspace package is named `nope`, now fails with `Package 'nope' not found in the workspace` and exits 1, including from a task's command, instead of running nothing and exiting 0. A short name that auto-completes to several scoped packages, like `app` for `@a/app` and `@b/app`, now fails as ambiguous. `--filter nope` still only warns and exits 0, unless `--fail-if-no-match` is set ([#984](https://github.com/voidzero-dev/vite-task/pull/984)). - **Added** `vp run -vv` also lists what each cached run depends on, changed or not, and the output files a hit restores: in the detailed summary, under `Unchanged:` and `Outputs:`, and with `--dry-run --json`, as each step's `baseline.fingerprint` and `baseline.outputs`. It shows, for an unexpected hit, whether an edited file is an input at all. `-v` is now a counted flag, so `-vv` is the same as `--verbose --verbose` ([#969](https://github.com/voidzero-dev/vite-task/pull/969)). - **Added** `vp run --dry-run --json` prints what a run would do as one JSON document for scripts, CI and coding agents: each task the run would run, the tasks it waits for, and each step's program, arguments and directory, with whether it would hit the cache and, if not, every change found. Like `vp run --json`, it's indented in a terminal and on one line when captured, and its `$schema` field points to a JSON Schema that describes each field. A task that runs `vp run` shows that run's own plan as its step. A step that waits on one that would write files first, by running or by restoring outputs, is `unknown`, since its files may change before it starts. `--json` with a task requires `--dry-run` ([#966](https://github.com/voidzero-dev/vite-task/pull/966), [#967](https://github.com/voidzero-dev/vite-task/pull/967), [#968](https://github.com/voidzero-dev/vite-task/pull/968)). diff --git a/crates/vt/src/session/mod.rs b/crates/vt/src/session/mod.rs index 4700b9c3e..16a8d596d 100644 --- a/crates/vt/src/session/mod.rs +++ b/crates/vt/src/session/mod.rs @@ -491,7 +491,19 @@ impl<'a> Session<'a> { let cwd = Arc::clone(&self.cwd); let task_graph = self.task_graph().await?; let current_package_path = task_graph.get_package_path_from_cwd(&cwd).cloned(); - let mut entries = task_graph.list_tasks().await?; + // Listing loads every package's config, including ones the run never + // reached. When one fails to load, a run that named a task reports the + // task as not found, as it would without the fallback, instead of an + // unrelated package's error. + let mut entries = match task_graph.list_tasks().await { + Ok(entries) => entries, + Err(error) => { + return Err(run_command.task_specifier.as_ref().map_or_else( + || error.into(), + |task_specifier| vt_plan::Error::NoTasksMatched(task_specifier.clone()).into(), + )); + } + }; entries.sort_unstable_by(|a, b| { a.task_display .package_name diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml index 504d5bf1e..b6014e555 100644 --- a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots.toml @@ -1,7 +1,7 @@ [[e2e]] name = "missing_task_with_unreached_broken_config" comment = """ -`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. Neither should `vt run ship`, a task `@test/app` doesn't define, but it falls back to listing every task, so it fails with `@test/broken`'s error instead of saying `Task "ship" not found`. With `--parallel`, which skips that fallback, the same command gets the not-found error. +`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. `vt run ship`, a task `@test/app` doesn't define, falls back to listing every task, which loads `@test/broken`'s config. When that fails, it reports `Task "ship" not found`, as `--parallel`, which skips the fallback, does, instead of `@test/broken`'s error. """ cwd = "packages/app" steps = [ @@ -17,16 +17,16 @@ steps = [ "vt", "run", "ship", - ], comment = "fails with @test/broken's error instead of `Task \"ship\" not found.`" }, + ], comment = "not found, without @test/broken's error" }, { argv = [ "vt", "run", "ship", - ], comment = "in a terminal, fails with the same error" }, + ], comment = "in a terminal, also not found, without the task selector" }, { argv = [ "vt", "run", "--parallel", "ship", - ], comment = "without the fallback, the same command is reported as not found" }, + ], comment = "without the fallback, also not found" }, ] diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md index 6831e373d..9e2369a80 100644 --- a/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/lazy_config_task_not_found/snapshots/missing_task_with_unreached_broken_config.md @@ -1,6 +1,6 @@ # missing_task_with_unreached_broken_config -`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. Neither should `vt run ship`, a task `@test/app` doesn't define, but it falls back to listing every task, so it fails with `@test/broken`'s error instead of saying `Task "ship" not found`. With `--parallel`, which skips that fallback, the same command gets the not-found error. +`packages/broken/vite-task.json` sets `cache`, which only the workspace root config may set. `vt run build` in `packages/app` never reads `@test/broken`'s config. `vt run ship`, a task `@test/app` doesn't define, falls back to listing every task, which loads `@test/broken`'s config. When that fails, it reports `Task "ship" not found`, as `--parallel`, which skips the fallback, does, instead of `@test/broken`'s error. ## `vt run build` @@ -13,28 +13,28 @@ Building app ## `vtt pipe-stdout -- vt run ship` -fails with @test/broken's error instead of `Task "ship" not found.` +not found, without @test/broken's error **Exit code:** 1 ``` -error: `cache` can only be set in the workspace root config, but found in /packages/broken +error: Task "ship" not found --- stdout --- ``` ## `vt run ship` -in a terminal, fails with the same error +in a terminal, also not found, without the task selector **Exit code:** 1 ``` -error: `cache` can only be set in the workspace root config, but found in /packages/broken +error: Task "ship" not found ``` ## `vt run --parallel ship` -without the fallback, the same command is reported as not found +without the fallback, also not found **Exit code:** 1