Skip to content

fix(core): resolve input files for targets with defaultConfiguration#34638

Open
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-empty-target-inputs
Open

fix(core): resolve input files for targets with defaultConfiguration#34638
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-empty-target-inputs

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

nx show target inputs returns empty results for any target with defaultConfiguration set because HashPlanInspector.inspectTaskInputs() keys results as project:target:config (e.g. my-app:build:local), but the lookup was using project:target — a guaranteed miss.

Changes

  • packages/nx/src/command-line/show/target.ts: In resolveInputFiles, construct the plan lookup key using the explicitly passed configuration first, then fall back to the target's defaultConfiguration:
const targetConfig = graph.nodes[projectName]?.data?.targets?.[targetName];
const effectiveConfig = configuration ?? targetConfig?.defaultConfiguration;
const taskId = effectiveConfig
  ? `${projectName}:${targetName}:${effectiveConfig}`
  : `${projectName}:${targetName}`;

If the computed taskId is not found in the hash plan, an error is thrown instead of silently returning empty results.

  • showTargetInputsHandler: Now extracts the configuration from the target string (project:target:config) or the -c/--configuration flag and forwards it to resolveInputFiles.

  • ShowTargetInputsOptions (command-object.ts): Added configuration?: string so the type correctly reflects the prop.

  • packages/nx/src/command-line/show/target.spec.ts: Added tests covering:

    • Resolving input files when defaultConfiguration is set
    • Preferring an explicit configuration over defaultConfiguration
    • Throwing when the task ID is not found in the hash plan
Original prompt

This section details on the original issue you should resolve

<issue_title>nx show target inputs returns empty when target has defaultConfiguration</issue_title>
<issue_description>## Current Behavior

nx show target inputs <project>:<target> --json returns no files for any target that has a defaultConfiguration set (directly or via targetDefaults).

$ nx show target inputs card-api-lambda:build --json
{
  "project": "card-api-lambda",
  "target": "build"
}
# Expected: files array with resolved input files

The --check flag also reports files as not being inputs when they should be:

$ nx show target inputs card-api-lambda:build --check packages/card/api/lambda/main.go
✗ packages/card/api/lambda/main.go is not an input for card-api-lambda:build

Targets without defaultConfiguration on the same project resolve correctly:

$ nx show target inputs card-api-lambda:generate-docs --json
{
  "project": "card-api-lambda",
  "target": "generate-docs",
  "files": [ ".gitignore", "nx.json", "packages/card/api/lambda/main.go", ... ]
}

Root Cause

In packages/nx/src/command-line/show/target.ts, the resolveInputFiles function constructs the lookup key as:

const taskId = `${projectName}:${targetName}`;

But the native HashPlanInspector.inspectTaskInputs() returns results keyed by the full task ID including the default configuration, e.g. card-api-lambda:build:local.

When a target has defaultConfiguration: "local", the plan result is keyed as project:target:local, but the lookup searches for project:target — which doesn't exist — so it falls through to the empty default { files: [], ... }.

Verified by calling inspectTaskInputs directly:

=== build ===
Task IDs in result: card-api-lambda:generate-docs, card-api-lambda:build:local
# lookup for "card-api-lambda:build" → miss → empty

=== generate-docs ===
Task IDs in result: card-api-lambda:generate-docs
# lookup for "card-api-lambda:generate-docs" → hit → 142 files

Suggested Fix

The lookup key should account for the default configuration:

const defaultConfig = graph.nodes[projectName]?.data?.targets?.[targetName]?.defaultConfiguration;
const taskId = defaultConfig
  ? `${projectName}:${targetName}:${defaultConfig}`
  : `${projectName}:${targetName}`;

Expected Behavior

nx show target inputs should resolve and display input files regardless of whether the target has a defaultConfiguration.

Environment

  • Nx version: 22.6.0-beta.3
  • OS: macOS (Darwin 24.6.0)
  • Node: v22
  • Package manager: pnpm</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit eb56670
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69a192d8f035be000894268c
😎 Deploy Preview https://deploy-preview-34638--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 27, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit eb56670
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69a192d8e22b720008c8d0cd
😎 Deploy Preview https://deploy-preview-34638--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix empty target inputs when defaultConfiguration is set fix(nx): resolve input files for targets with defaultConfiguration Feb 27, 2026
const targetConfig = graph.nodes[projectName]?.data?.targets?.[targetName];
const defaultConfig = targetConfig?.defaultConfiguration;
const taskId = defaultConfig
? `${projectName}:${targetName}:${defaultConfig}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this should respect the passed in configuration prop if available. We should also throw if the config isnt in the inspected hash plan instead of silently passing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f12f6f7. The resolveInputFiles function now:

  1. Prefers the explicitly passed configuration over defaultConfiguration: const effectiveConfig = configuration ?? targetConfig?.defaultConfiguration;
  2. Throws if the task ID is not found in the hash plan instead of silently returning empty defaults

Also updated showTargetInputsHandler to extract the configuration from the target string (project:target:config) or the -c flag and forward it to resolveInputFiles.

Co-authored-by: AgentEnder <6933928+AgentEnder@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.gradle.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -XX:MaxMetaspaceSize=384m -XX:&#43;HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • staging.nx.app
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./bin/post-install (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node /home/REDACTED/work/nx/nx/node_modules/.pnpm/nx@22.6.0-beta.5_@swc-node&#43;register@1.11.1_@swc&#43;core@1.15.10_@swc&#43;helpers@0.5.18__@swc&#43;_a827ebc424be037fc154d90301143d4e/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker /tmp/plugin4313-16-465.108282.sock @nx/enterprise-cloud (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node /home/REDACTED/work/nx/nx/node_modules/.pnpm/nx@22.6.0-beta.5_@swc-node&#43;register@1.11.1_@swc&#43;core@1.15.10_@swc&#43;helpers@0.5.18__@swc&#43;_a827ebc424be037fc154d90301143d4e/node_modules/nx/src/project-graph/plugins/isolation/plugin-worker /tmp/plugin5191-16-483.549491.sock @nx/enterprise-cloud (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@AgentEnder AgentEnder changed the title fix(nx): resolve input files for targets with defaultConfiguration fix(core): resolve input files for targets with defaultConfiguration Feb 27, 2026
@nx-cloud
Copy link
Contributor

nx-cloud bot commented Feb 27, 2026

View your CI Pipeline Execution ↗ for commit eb56670

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 56m 9s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 22s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-27 13:49:39 UTC

Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ The fix from Nx Cloud was applied automatically

We've applied Prettier formatting to resolve the format:check failure in target.ts. The formatter adjusted the line wrapping of the destructuring assignment to comply with the project's code style guidelines, ensuring the changes from the defaultConfiguration fix meet formatting standards.

Tip

We verified this fix by re-running nx-cloud record -- nx format:check.

Suggested Fix changes
diff --git a/packages/nx/src/command-line/show/target.ts b/packages/nx/src/command-line/show/target.ts
index 631f7fc3eb..f3d0feca10 100644
--- a/packages/nx/src/command-line/show/target.ts
+++ b/packages/nx/src/command-line/show/target.ts
@@ -73,11 +73,8 @@ export async function showTargetInputsHandler(
   const graph = await createProjectGraphAsync();
   const nxJson = readNxJson();
 
-  const { projectName, targetName, configurationName } = resolveTargetIdentifier(
-    args,
-    graph,
-    nxJson
-  );
+  const { projectName, targetName, configurationName } =
+    resolveTargetIdentifier(args, graph, nxJson);
 
   const node = resolveProjectNode(projectName, graph);
   const targetConfig = node.data.targets?.[targetName];

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.

Revert fix via Nx Cloud  

View interactive diff ↗

🎓 Learn more about Self-Healing CI on nx.dev

Co-authored-by: Copilot <Copilot@users.noreply.github.com>
@AgentEnder AgentEnder marked this pull request as ready for review February 27, 2026 20:11
@AgentEnder AgentEnder requested a review from a team as a code owner February 27, 2026 20:11
@AgentEnder AgentEnder requested a review from MaxKless February 27, 2026 20:11
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.

nx show target inputs returns empty when target has defaultConfiguration

2 participants