feat(core): suggest available targets and closest task id on run-one errors#35863
Open
AgentEnder wants to merge 3 commits into
Open
feat(core): suggest available targets and closest task id on run-one errors#35863AgentEnder wants to merge 3 commits into
AgentEnder wants to merge 3 commits into
Conversation
…errors - When `nx run <project>:<target>` references an unknown target, list up to 5 available targets and surface the closest match as 'Did you mean ...?'. - When the project itself is unknown, match the attempted `project:target[:configuration]` against every `project:target` task id in the graph so project typos (e.g. `webpai:build`) suggest the real invocation (`webapi:build`). - Handle colon-containing target/configuration names: when `splitTarget` parses the trailing segment off into a configuration, the rejoined specifier is tried first, then progressively shorter forms - so `nx:zzcustom:variantt` still suggests `zzcustom:variant`, while genuine `target` + `configuration` typos (`biuld:production` -> `build`) keep working via the shorter-form fallback. - New `findClosestMatches` / `findClosestMatch` Levenshtein helper with a length-relative threshold (no suggestion for total nonsense). - Update e2e assertion for the friendlier message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit d367664
☁️ Nx Cloud last updated this comment at |
…errors [Self-Healing CI Rerun]
…errors [Self-Healing CI Rerun]
Contributor
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.
🎓 Learn more about Self-Healing CI on nx.dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
When
nx runcan't resolve the project or target, the error gives no guidance:Cannot find configuration for task <project>:<target>— no list of what is available, no spelling help.Cannot find project '<name>'with no suggestion of what the user might have meant.:(a legal target name in Nx) gets parsed into separatetarget+configurationparts bysplitTarget, so any naive similarity match against the baretargetcan never find the real colon-containing name.Expected Behavior
run-onenow validates the project and target up front and produces a friendly error before reaching the task-graph stage.Unknown target:
...and N moreline so output stays scannable on big projects.Did you meansuggestion uses Levenshtein distance with a length-relative threshold, so it stays silent for total nonsense.Unknown project — including a colon target:
The attempted
project:target[:configuration]is matched against everyproject:targettask id in the graph, so project typos surface the real invocation (webpai:build→webapi:build), and project typos against colon-named targets still resolve (nxx:zzcustom:variant→nx:zzcustom:variant).Colon-containing target/configuration names:
Because
splitTargetparses the trailing segment off into a configuration, both error builders try the fully rejoined specifier first, then progressively shorter forms. Sonx:zzcustom:varianttsuggestszzcustom:variant, while genuinetarget+configurationtypos (biuld:production→build) keep matching via the shorter-form fallback.Implementation notes
packages/nx/src/utils/string-similarity.tswithfindClosestMatch/findClosestMatches(Levenshtein + length-relative threshold).run-one.tsadds exported, unit-testable helpersgetRunOneTargetErrorandgetCannotFindProjectError, a sharedfindClosestSpecifierthat tries longest-first, andformatAvailableTargetsfor the capped list.echo:faile2e is updated to assert the new message.Related Issue(s)