Skip to content

Conversation

meeroslav
Copy link
Contributor

Current Behavior

Env variables from the parent target are not propagated to the atomized target e.g.
.test-ci.env will be only applied to no-op test-ci but not to test-ci--path/to/test/file.

Expected Behavior

Running an atomized target will load from the parent's env files.

Related Issue(s)

Fixes #

@meeroslav meeroslav self-assigned this Oct 8, 2025
@meeroslav meeroslav requested a review from a team as a code owner October 8, 2025 11:45
@meeroslav meeroslav requested a review from MaxKless October 8, 2025 11:45
@meeroslav meeroslav added the scope: core core nx functionality label Oct 8, 2025
Copy link

vercel bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Oct 9, 2025 3:56pm

Copy link
Contributor

nx-cloud bot commented Oct 8, 2025

View your CI Pipeline Execution ↗ for commit 494624e

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 33m 37s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 1m 46s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 7s View ↗
nx documentation ✅ Succeeded 2m 49s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-09 16:21:45 UTC

Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 494624e
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/68e7d6c7e67f3300086a6c32
😎 Deploy Preview https://deploy-preview-33013--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.

}

function getEnvFilesForTask(task: Task): string[] {
const target = task.target.target.split('--')[0];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this would be less brittle/hacky if we passed the project graph into here and used the atomization metadata to determine the parent task vs basing it purely on the task name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I wasn't sure about modifying the public caller with graph reference but i guess it's the only way to be sure.

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.

Nx Cloud has identified a possible root cause for your failed CI:

The failing test "e2e-angular:e2e-ci--src/projects-linting.test.ts" encountered a package installation failure during test setup, not a failure related to the pull request's changes.

Pull Request Intent:
The PR implements functionality to propagate parent target environment variables to atomized targets. When Nx atomizes a target (splits it into individual test files like "test--path/to/file.ts"), the changes ensure that environment variables defined for the parent target (e.g., in ".test.env") are correctly applied to the atomized child targets.

The implementation adds:

  • A new function "getOwnerTargetForTask()" that uses the project graph to identify the parent target for atomized tasks by checking "project.data.metadata.targetGroups"
  • Updates to "getTaskSpecificEnv()" and related functions to accept and use the project graph parameter
  • Logic to resolve the parent target name from atomized target names when loading environment files

Error Analysis:
The test failed with "ERR_PNPM_FETCH_404 GET http://localhost:4873/retry: Not Found - 404" during the installation of @nx/angular@22.0.0 dependencies. The package "retry" (a transitive dependency via @nx/rspack -> @rspack/dev-server -> p-retry -> retry) was not available in the local e2e test registry.

Why This Is An Environment Issue:

  1. The error occurs during package installation, before any Nx task execution or environment variable loading
  2. The local registry at localhost:4873 is missing the "retry" package, indicating an incomplete or corrupted registry state
  3. The code changes only affect runtime environment variable resolution for tasks, not the package installation process
  4. No similar failures appear in the master branch's task outputs, suggesting this is a transient registry issue
  5. The failure happened during test setup when running "pnpm add -D @nx/angular@22.0.0", which is completely independent of the env variable propagation logic

No Code Fix Required:
This is an infrastructure issue with the e2e test environment's local npm registry. The PR's changes to environment variable handling for atomized targets are unrelated to package resolution. The test should pass when the registry is properly populated with all required dependencies.

A code change would likely not resolve this issue, so no action was taken.

Nx CloudView in Nx Cloud ↗


⚙️ An Nx Cloud workspace admin can disable these reviews in workspace settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: core core nx functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants