Skip to content

nx show target inputs returns empty when target has defaultConfiguration #34594

@Hoffs

Description

@Hoffs

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

Metadata

Metadata

Labels

priority: highHigh Priority (important issues which affect many people severely)scope: corecore nx functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions