Visitar URL original
fix(core): keep cache restores and stores inside task outputs by AgentEnder · Pull Request #37661 · nrwl/nx · GitHub
Skip to content

fix(core): keep cache restores and stores inside task outputs - #37661

Merged
AgentEnder merged 10 commits into
masterfrom
fix/core-cache-restore-paths
Nov 3, 2026
Merged

AgentEnder merged 10 commits into
masterfrom
fix/core-cache-restore-paths

Conversation

@AgentEnder

Copy link
Copy Markdown
Member

Current Behavior

  • Nx restores a remote cache artifact even when a symlink in its outputs resolves outside the output it sits in.
  • A literal output is cached whenever its path exists, even when a parent directory is a symlink, so Nx reads and stores files from the link target.
  • Restoring a glob output turns every parent of each matched path into a directory, replacing any file or symlink there. Below the glob's literal root those names come from the artifact.
  • With negated outputs, a cached file or link at the path of a workspace directory removes that whole directory on restore, including the excluded paths.
  • The legacy Nx Cloud adapter replays an artifact's code, terminalOutputs and outputs entries without checking what kind of entry each one is.

Expected Behavior

  • A remote artifact with a link that leaves its output is discarded before anything is restored. Nx warns and runs the task. Local hits restore as before.
  • Literal outputs follow the rule the glob walk already applies, and an output with a trailing slash isn't resolved through a link at its own path.
  • A restore refuses when a non-directory occupies a parent below the glob's literal root. Parents the configuration names are still replaced.
  • That restore fails instead of removing the directory.
  • The legacy adapter treats the artifact as a miss unless code and terminalOutputs are regular files and outputs is a directory.

Notes for reviewers

  • A remote artifact whose links point outside the output (for example into workspace node_modules) now misses and rebuilds with a warning.
  • A literal output under a symlinked parent, such as dist linked to another disk, is no longer cached. Glob outputs already behaved this way.
  • The two restore refusals surface as restore errors and go through the existing handling.
  • The WASM-only legacy Cache class isn't covered.

Related Issue(s)

None.

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-MX4VEX84.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-XPGD2SDT.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-8URRE527.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-I61QNYG4.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-XCYIOQSH.

@netlify

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 2cd31cb
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6ae4e0846f8e571363ceb1bb
😎 Deploy Preview https://deploy-preview-37661--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

netlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 2cd31cb
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6ae4e08435688378ee00ebdc
😎 Deploy Preview https://deploy-preview-37661--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.

@nx-cloud

nx-cloud Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 2cd31cb

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 1h 8m 23s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 59s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 37s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-30 19:36:11 UTC

…s as misses

A remote cache artifact whose outputs hold a symlink that does not resolve
inside the output it sits in is now discarded before anything is restored.
Nx warns and runs the task instead of replaying the result. Local cache hits
are restored as before.
A literal output was kept whenever its path existed, even when a parent
directory was a symlink, so the cache read and stored files from wherever
the link pointed. Literal outputs now follow the same rule the glob walk
already applies, and an output written with a trailing slash is no longer
resolved through a link at its own path.
…ing from cache

Restoring a glob output realized every parent of each matched path as a
directory, replacing whatever file or symlink sat there. Below the glob's
literal root those parent names come from the cached artifact, not the
configuration, so the restore could remove workspace files that are not
outputs of the task. Restore now refuses when a non-directory occupies such
a parent. Parents the configuration names, and paths inside a literal
output, are still replaced as before.
…directory

With negated outputs, a cached file or link at the path of a workspace
directory removed that directory whole on restore, including the paths
the negations exclude. The restore now fails instead.
…acts

The legacy Nx Cloud adapter now treats a retrieved artifact as a cache
miss when its code or terminalOutputs entry is not a regular file, or
its outputs entry is not a directory.
…ot be read

Terminal outputs are optional, so a read failure falls back to the other
log or to none instead of failing the cache lookup.
The directory check before a restore no longer follows a link the copy
replaces with a real directory, so files at the link's target cannot
refuse an otherwise valid restore.
…rectory

A literal output that exists only through a linked directory is not
copied into the cache. Storing the task anyway recorded and uploaded a
hit that restores nothing, so the task is now left uncached with a
warning naming those outputs.
@AgentEnder
AgentEnder force-pushed the fix/core-cache-restore-paths branch from e8fc2ff to 2cd31cb Compare October 30, 2026 18:22

@jaysoo jaysoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Ran the native cache tests (79 pass) and the db-cache / default-tasks-runner specs in a sandbox; each new case asserts behaviour the base lacks, so none of them pass on master. The four behaviour changes called out in the body (outputs under a symlinked parent never cached, links leaving their output root discarded, dir-below-glob-root restore errors, failed results walked) all match the code. A few non-blocking questions and suggestions may follow separately.

@AgentEnder
AgentEnder marked this pull request as ready for review October 30, 2026 21:07
@AgentEnder
AgentEnder requested a review from a team as a code owner October 30, 2026 21:07
@AgentEnder
AgentEnder merged commit 2e0b8f2 into master Nov 3, 2026
25 checks passed
@AgentEnder
AgentEnder deleted the fix/core-cache-restore-paths branch November 3, 2026 14:23
jaysoo pushed a commit that referenced this pull request Nov 3, 2026
## Current Behavior

- Nx restores a remote cache artifact even when a symlink in its outputs
resolves outside the output it sits in.
- A literal output is cached whenever its path exists, even when a
parent directory is a symlink, so Nx reads and stores files from the
link target.
- Restoring a glob output turns every parent of each matched path into a
directory, replacing any file or symlink there. Below the glob's literal
root those names come from the artifact.
- With negated outputs, a cached file or link at the path of a workspace
directory removes that whole directory on restore, including the
excluded paths.
- The legacy Nx Cloud adapter replays an artifact's `code`,
`terminalOutputs` and `outputs` entries without checking what kind of
entry each one is.

## Expected Behavior

- A remote artifact with a link that leaves its output is discarded
before anything is restored. Nx warns and runs the task. Local hits
restore as before.
- Literal outputs follow the rule the glob walk already applies, and an
output with a trailing slash isn't resolved through a link at its own
path.
- A restore refuses when a non-directory occupies a parent below the
glob's literal root. Parents the configuration names are still replaced.
- That restore fails instead of removing the directory.
- The legacy adapter treats the artifact as a miss unless `code` and
`terminalOutputs` are regular files and `outputs` is a directory.

### Notes for reviewers

- A remote artifact whose links point outside the output (for example
into workspace `node_modules`) now misses and rebuilds with a warning.
- A literal output under a symlinked parent, such as `dist` linked to
another disk, is no longer cached. Glob outputs already behaved this
way.
- The two restore refusals surface as restore errors and go through the
existing handling.
- The WASM-only legacy `Cache` class isn't covered.

## Related Issue(s)

None.

Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-MX4VEX84.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-XPGD2SDT.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-8URRE527.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-I61QNYG4.
Discovered by Anthropic's OSS Scanner, as vulnerability
ANT-2026-XCYIOQSH.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants