Repository navigation
[1.0-beta] fix: auth private git module deps during SDK-as-module codegen - #13309
Merged
Merged
Conversation
eunomie
force-pushed
the
fix-go-sdk-private-dep-gen
branch
4 times, most recently
from
June 3, 2026 06:49
0608db5 to
c21fc6c
Compare
`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
force-pushed
the
fix-go-sdk-private-dep-gen
branch
from
June 3, 2026 08:28
c21fc6c to
96b6fac
Compare
eunomie
marked this pull request as ready for review
June 3, 2026 10:10
tiborvass
approved these changes
Jun 4, 2026
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
dagger generateagainst 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:dagger develop, a public dependency, and a manualdagger -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 generateruns the go-sdk module'sgenerate-allgenerator 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 initresolve 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), viaengine.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 viadagger workspace init→dagger install github.com/dagger/go-sdk→dagger generate, reusing the existinggetVCSTestCase/privateRepoSetup/testGitModuleRefhelpers (uses the repo's existing CI git credentials).Verification
go build ./core/,go vet ./core/integration/,gofmtclean.dagger generatedrivesgo-sdk:generate-all→generatedContextChangeset→go SDK: run codegenand regeneratesdagger.gen.go— i.e. the dependency is resolved inside the nested-client generator, and the change does not break public-dependency generation.Tracking: #13296.