Skip to content

Commit

Permalink
fix(core): improve error for setting an internal node as an external … (
Browse files Browse the repository at this point in the history
#27102)

…dependency

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

A unhelpful error is thrown when someone specifies a local project as an
external dependency input.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

A helpful error is thrown when someone specifies a local projecft as an
external dependency input.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27088

(cherry picked from commit fc1ad39)
  • Loading branch information
FrozenPandaz committed Jul 24, 2024
1 parent 54d9b4f commit 5aad26f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/nx/src/native/tasks/hash_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,16 @@ impl HashPlanner {
let external_node_name =
find_external_dependency_node_name(dep, &self.project_graph);
let Some(external_node_name) = external_node_name else {
anyhow::bail!("The externalDependency '{dep}' for '{project_name}:{target_name}' could not be found")
if self.project_graph.nodes.contains_key(dep) {
let deps = self.project_graph.dependencies.get(project_name);
if deps.is_some_and(|deps| deps.contains(dep)) {
anyhow::bail!("The externalDependency '{dep}' for '{project_name}:{target_name}' is not an external node and is already a dependency. Please remove it from the externalDependency inputs.")
} else {
anyhow::bail!("The externalDependency '{dep}' for '{project_name}:{target_name}' is not an external node. If you believe this is a dependency, add an implicitDependency to '{project_name}'")
}
} else {
anyhow::bail!("The externalDependency '{dep}' for '{project_name}:{target_name}' could not be found")
}
};
trace!(
"Add External Instruction for External Input {external_node_name}: {}",
Expand Down

0 comments on commit 5aad26f

Please sign in to comment.