Skip to content

fix(container): preserve cache identity through registry auth - #13901

Merged
sipsma merged 2 commits into
dagger:mainfrom
sipsma:fix/registry-auth-cache-identity
Aug 14, 2026
Merged

sipsma merged 2 commits into
dagger:mainfrom
sipsma:fix/registry-auth-cache-identity

Conversation

@sipsma

@sipsma sipsma commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep registry authentication as session-local state without making it part of semantic container result identity
  • return the attached parent ObjectResult from withRegistryAuth and withoutRegistryAuth, since they mutate ambient session auth rather than the container
  • conservatively allow Container.from to publish stable image content identity only for an untouched scratch container
  • cover cross-session cache reuse with auth both before and after From, plus constructor/clone defaults and modified-container MultiFrom preservation

Problem

Adding registry credentials to an otherwise unchanged container caused image pulls and downstream executions to miss cache across Dagger sessions. This was especially visible for the common sequence container -> withRegistryAuth -> from(image) -> downstream operations, even when the configured credentials were unrelated to the pulled image.

The root cause was that the auth mutation was scoped correctly with dagql.PerSessionInput, but dagql.Func wrapped the unchanged Go container pointer in a new result whose identity included that session-local input. Session-local auth side effects were therefore coupled to semantic container result identity.

Approach

withRegistryAuth and withoutRegistryAuth are now NodeFuncs that still execute against the current session's auth provider, but return the already-attached parent result. The e-graph can therefore treat the returned container as exactly the unchanged semantic value it is, allowing downstream cache reuse across sessions.

Container.from no longer identifies the safe path by inspecting the parent field name. A newly constructed scratch container carries a private safety bit, while schema child cloning defaults it to false. This keeps stable image content identity available for untouched containers while conservatively preserving call identity for genuinely modified containers whose state survives From.

This takes a different approach from the now-closed #13899: it retains normal per-session caching and restores result equivalence instead of marking registry-auth operations DoNotCache.

Validation

  • go test ./core ./core/schema -count=1
  • dagger api call engine-dev test --pkg ./core/integration --run='^TestContainer/(TestMultiFrom|TestWithRegistryAuth.*)$' — 8 passed
  • git diff --check
  • dagger generate -y — dagger-go-sdk:generate passed; the overall run was blocked in the unrelated Elixir generator because the BEAM runtime aborted with OS monotonic time stepped backwards (exit 134); no generated changes were produced
  • dagger check '*:lint' — Helm, Java, Markdown, and Python passed; elixir-client:lint hit the same BEAM host-clock abort

Closes #13898.

sipsma added 2 commits August 14, 2026 20:35
Return the attached container result from session-local registry auth mutations, and conservatively gate image content identity on an untouched scratch container.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma merged commit 06aee1f into dagger:main Aug 14, 2026
88 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.9

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v0.21.9 - 2026-08-25

### Added
- Added SSHFS-backed volumes, allowing remote filesystems to be mounted into containers without copying their contents into Dagger's content store by @sipsma in dagger/dagger#13462

### Fixed
- `Container.withDirectory` and `Directory.withDirectory` no longer restore by @sipsma in dagger/dagger#13848 \
  deleted nested files after execs remove and recreate an ancestor
  directory.
- Engine client enumeration no longer blocks behind another session's by @sipsma in dagger/dagger#13542 \
  initialization or teardown, preventing Cloud keeper heartbeats from stalling
  and live engines from being suspended.
- Session teardown now runs in the background after the main client disconnects, by @sipsma in dagger/dagger#13681 \
  preventing shutdown responses from timing out while the engine releases
  session-owned cache results.
- The engine now bounds retained DAGQL cache metadata independently of disk by @sipsma in dagger/dagger#13846 \
  usage by pruning cold persisted results when the structural estimate exceeds
  its configured limit. This may mitigate metadata growth at scale while
  preserving active and engine-lifetime cache roots.
- Registry protocol probes no longer appear as scary errors in progress output by @vito in dagger/dagger#13410 \
  when image pulls or publishes succeed, while genuine registry failures remain
  visible.
- Registry authentication no longer invalidates downstream container cache reuse across sessions when applied before or after `Container.from` by @sipsma in dagger/dagger#13901

### What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</pre>
  <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.9">https://github.com/dagger/dagger/releases/tag/v0.21.9</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!17786
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.

🐞 withRegistryAuth invalidates image and execution caches across sessions

2 participants