Skip to content

fix(engine): refresh registry auth per resolver operation - #13256

Merged
sipsma merged 1 commit into
dagger:mainfrom
sipsma:reg-auth-bug
May 29, 2026
Merged

sipsma merged 1 commit into
dagger:mainfrom
sipsma:reg-auth-bug

Conversation

@sipsma

@sipsma sipsma commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cache registry host configs without attached containerd Docker authorizers
  • attach fresh operation-scoped authorizers for pull and push registry host callbacks
  • mark withoutRegistryAuth as per-session input, matching withRegistryAuth
  • add an integration regression for anonymous Bearer pull followed by authenticated publish to the same registry

Root Cause

Resolver.hostCache stored docker.RegistryHost values after attaching docker.NewDockerAuthorizer. Those authorizers are stateful: after an anonymous Bearer pull, the cached authorizer can keep using the anonymous token flow even when the same Dagger client session later calls withRegistryAuth before publishing to that registry.

That makes an authenticated publish fail with an anonymous token request for the private push scope. This showed up with GHCR in CI after the outer engine moved to v0.21.0, and it reproduced locally with a registry that allows anonymous access to a public repo but requires credentials for a private repo.

Fix

The resolver now caches only the stable registry host configuration: scheme, host, path, client, headers, and capabilities. Pull and push registry host callbacks clone those configs and attach operation-scoped authorizers. This preserves the useful host config reuse while letting each resolver operation observe the current Dagger auth provider state.

The withoutRegistryAuth schema function also gets dagql.PerSessionInput because it mutates session-local registry auth state, just like withRegistryAuth.

Validation

  • git diff --check
  • go test ./engine/server/resolver ./auth -count=1
  • dagger --progress=plain call engine-dev test --pkg ./core/integration --run="TestContainer/TestWithRegistryAuthAfterAnonymousBearerPull" passed after rebasing onto current upstream/main; log: /tmp/reg-auth-bearer-test-post-rebase.log
  • dagger --progress=plain call engine-dev test --pkg ./core/integration --run="TestContainer" was run; the new regression passed there too, but the suite failed in TestSystemCACerts/wolfi_basic and TestWithMountedDirectoryCaching, which look unrelated to this registry auth change; log: /tmp/reg-auth-testcontainer.log

@sipsma sipsma added this to the v0.21.1 milestone May 28, 2026
@sipsma sipsma changed the title [codex] fix(engine): refresh registry auth per resolver operation fix(engine): refresh registry auth per resolver operation May 28, 2026
@sipsma
sipsma marked this pull request as ready for review May 28, 2026 22:53
Registry host configs were cached with containerd Docker authorizers attached. Those authorizers are stateful: after an anonymous Bearer pull, the authorizer can keep using the anonymous token flow even if the same session later adds credentials with withRegistryAuth before publishing to that registry.

Cache only the base registry host configuration and attach fresh operation-scoped authorizers when constructing pull and push registry host callbacks. This preserves host/client/header reuse while ensuring each resolver operation observes the current Dagger auth provider state.

Also mark withoutRegistryAuth as per-session input to match withRegistryAuth, since removing registry credentials mutates session-local auth state.

Add an integration regression that pulls a public Bearer-protected image anonymously, then publishes to a private repository on the same registry after withRegistryAuth. The test fails before the resolver change because the publish attempts an anonymous token request for the private scope.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma merged commit 893e4de into dagger:main May 29, 2026
78 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.1

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.1 - 2026-05-29

### Added
- Add native GraphQL interfaces and unified object IDs in DagQL by @vito in dagger/dagger#12041 \
  Dagger now exposes objects through the standard `Node` interface and `ID` scalar, enabling APIs to accept generic Dagger objects while preserving SDK compatibility through legacy `FooID` and `loadFooFromID` views for older clients.

### Fixed
- Python SDK: fix unhandled module registration cases and bugs by removing the AST-based module analyzer and returning to runtime introspection by @eunomie in dagger/dagger#13251
- Fix Go module generation to avoid unnecessary dependency churn in generated `go.mod` and `go.sum` files by @sipsma in dagger/dagger#13244
- Fix registry authentication so `withRegistryAuth` credentials are not incorrectly skipped and authenticated publishes keep working after anonymous pulls to the same registry by @marcosnils + @sipsma in dagger/dagger#13255 dagger/dagger#13256
- Fix published image layer structure so `withDirectory` and `withFile` operations preserve expected layer boundaries instead of being squashed into a few large layers by @sipsma in dagger/dagger#13242
- Fix Dockerfile `RUN --mount=type=bind` conversion when the bind source selector points to a regular file, improving compatibility with file and directory bind mounts by @sipsma in dagger/dagger#13273
- Fix module source cache dependency retention, including ephemeral `missing shared result` errors after cache persistence or engine restarts by @sipsma in dagger/dagger#13243
- Fix a bug where some cache entries did not have their size calculated during background and shutdown pruning by @sipsma in dagger/dagger#13225
- Fix repeated `op://` 1Password secret reads by caching resolved 1Password secret values during a run, avoiding provider rate limits when the same secret is mounted or read multiple times by @matipan in dagger/dagger#13249
- Fix Windows Changeset exports so `RemovePaths` entries cannot remove files outside the selected export root through backslash or absolute-path interpretation by @marcosnils in dagger/dagger#13222
- Fix `dagger --x-release` for tagged releases so semver refs download release artifacts instead of looking in the main-build artifact namespace, and prevent local runner override environment from leaking into the re-executed CLI by @grouville in dagger/dagger#13259

### 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.1">https://github.com/dagger/dagger/releases/tag/v0.21.1</a>.</p>
</details>
<hr>

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

2 participants