Skip to content

[1.0-beta] fix: auth private git module deps during SDK-as-module codegen - #13309

Merged
tiborvass merged 3 commits into
dagger:1.0-betafrom
eunomie:fix-go-sdk-private-dep-gen
Jun 4, 2026
Merged

tiborvass merged 3 commits into
dagger:1.0-betafrom
eunomie:fix-go-sdk-private-dep-gen

Conversation

@eunomie

@eunomie eunomie commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Problem

dagger generate against a module that declares a private git dependency, using an SDK-as-module (e.g. github.com/dagger/go-sdk), fails to authenticate the dependency:

export generated context ... failed to resolve dep to source: failed to load git dep:
failed to resolve git src: ... git error: git authentication failed
git ls-remote --symref https://gitlab.com/<private-repo>.git
remote: HTTP Basic: Access denied.

dagger develop, a public dependency, and a manual dagger -m core call git --url <same-private-repo> all work — so the engine can authenticate; it just doesn't on this path.

Root cause

dagger generate runs the go-sdk module's generate-all generator as module code, i.e. under a nested module client rather than the user's main client. The dependency is resolved inside that nested execution:

go-sdk:generate-all → generatedContextChangeset → runCodegen → loadDependencyModules → ResolveDepToSource → dag.git(...)

The git resolver (core/schema/git.go) only forwards the host's implicit credentials when the current client is the non-module parent client ("only handle PAT auth if we're the main client"). Under the nested generator client the guard skips credential resolution, so the fetch is unauthenticated → access denied.

dagger develop / dagger init resolve dependencies under the main client, so the guard passes — which is why this only regressed once SDKs moved to modules.

Fix

Resolve declared git dependencies under the non-module parent client in ResolveDepToSource (core/modulesource.go), via engine.ContextWithClientMetadata(ctx, NonModuleParentClientMetadata(ctx)). This mirrors the existing idempotent idiom already used in this file for local source access (e.g. LoadUserDefaults), and is a no-op for top-level (main-client) resolution.

Scoped to declared-dependency resolution: a module calling dag.moduleSource("private-url") at runtime still fetches its top-level source through the unchanged guard, so this does not grant arbitrary module code implicit access to host credentials.

Test

TestGeneratePrivateGitDependency (core/integration/module_private_deps_test.go): a Go-SDK module declaring a private GitLab dependency, generated via dagger workspace init → dagger install github.com/dagger/go-sdk → dagger generate, reusing the existing getVCSTestCase/privateRepoSetup/testGitModuleRef helpers (uses the repo's existing CI git credentials).

Verification

  • go build ./core/, go vet ./core/integration/, gofmt clean.
  • Dev engine builds + boots with the change.
  • Playground (public dependency): confirmed dagger generate drives go-sdk:generate-all → generatedContextChangeset → go SDK: run codegen and regenerates dagger.gen.go — i.e. the dependency is resolved inside the nested-client generator, and the change does not break public-dependency generation.
  • The private-dependency red→green is exercised by the new integration test in CI (it depends on CI git secrets).

Tracking: #13296.

@eunomie
eunomie force-pushed the fix-go-sdk-private-dep-gen branch 4 times, most recently from 0608db5 to c21fc6c Compare June 3, 2026 06:49
eunomie added 3 commits June 3, 2026 09:48
`dagger generate` runs an SDK module's generator (e.g. github.com/dagger/go-sdk)
as module code, and codegen itself runs in a further nested exec. Resolving the
module's declared git dependencies (and git-based SDK) happens under those nested
clients, whose context may hold neither the user's git config nor a git binary.
The git resolver only forwards the host's implicit credentials for the main
client, so resolving a private dependency failed with "git authentication
failed" — even though `dagger develop` and `dagger -m <private-ref>` both worked.

Mark module dependency/SDK resolution on the context: it is trusted resolution
performed on the user's behalf (the refs come from a module's dagger.json). The
git resolver uses this marker to source the user's credentials even when the
immediate caller is a nested client (implemented in core/schema/git.go).

Signed-off-by: Yves Brissaud <[email protected]>
…resolution

When resolving a module's declared git dependency or SDK under a nested client
(e.g. a git-less codegen exec spawned during `dagger generate`), the git resolver
could not obtain the user's credentials: the immediate caller isn't the main
client, and the nearest non-module parent may be a codegen exec that holds
neither the user's git config/credential helper nor a git binary.

For trusted module dependency/SDK resolution (marked via
WithModuleDependencyResolution), try the non-module parent client's credentials
first and fall back to the session's originating (main) client — for both HTTP
credential helpers and the default SSH auth socket. Untrusted/arbitrary git
access from module runtime code is unaffected and still does not implicitly use
host credentials.

Signed-off-by: Yves Brissaud <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the fix-go-sdk-private-dep-gen branch from c21fc6c to 96b6fac Compare June 3, 2026 08:28
@eunomie
eunomie marked this pull request as ready for review June 3, 2026 10:10
@eunomie
eunomie requested a review from a team as a code owner June 3, 2026 10:10
@dagger-codex dagger-codex Bot changed the title fix: auth private git module deps during SDK-as-module codegen [1.0-beta] fix: auth private git module deps during SDK-as-module codegen Jun 3, 2026
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