Skip to content

fix(auth): forward Go auth to typedef generation - #13457

Merged
grouville merged 2 commits into
dagger:mainfrom
grouville:fix/private-transitive-go-deps
Jun 16, 2026
Merged

grouville merged 2 commits into
dagger:mainfrom
grouville:fix/private-transitive-go-deps

Conversation

@grouville

Copy link
Copy Markdown
Member

Summary

Fixes #13056.

Go SDK module loading could fail before invoking the requested function when the module's existing go.mod included a private transitive Go dependency.

The failure happened during codegen generate-typedefs: after the Go SDK library pinning change, typedef generation runs Go module resolution to pin dagger.io/dagger and github.com/dagger/querybuilder. That resolution also loads the user's existing go.mod graph, but ModuleTypes was not applying the same auth/dependency setup as normal Go SDK codegen.

This PR applies the Go SDK dependency configuration to typedef generation too:

  • SDK config selectors, including GOPRIVATE
  • forwarded Git config
  • forwarded SSH_AUTH_SOCK
  • cleanup selectors after codegen runs

baseWithCodegen keeps its existing withoutDefaultArgs behavior. ModuleTypes intentionally does not add it, because it did not use it before and the bug only requires forwarding dependency/auth configuration.

Test Coverage

Adds an integration test for a Go SDK module with:

  • an existing go.mod
  • a direct private Go module dependency
  • a private transitive Go module dependency

The fixture lives in grouville/daggerverse-private and is accessed with a read-only GitHub deploy key scoped to that repo.

Validation

dagger call engine-dev test \
  --pkg ./core/integration \
  --run '^TestModule/TestPrivateDeps/golang transitive existing go\.mod$' \
  --test-verbose

Trace:
https://dagger.cloud/dagger/traces/4b38ec36b3f981d060f8a57956859ee1

@grouville
grouville force-pushed the fix/private-transitive-go-deps branch 2 times, most recently from 6525f46 to 01f5c25 Compare June 16, 2026 02:38
@marcosnils marcosnils self-assigned this Jun 16, 2026

@marcosnils marcosnils left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Left a small nit comment.

@marcosnils marcosnils modified the milestones: v0.21.6, v0.21.7 Jun 16, 2026
@grouville
grouville force-pushed the fix/private-transitive-go-deps branch from 01f5c25 to 1021109 Compare June 16, 2026 18:54
Issue dagger#13056 reports that Go SDK codegen fails when a module's existing
go.mod imports a private Go module that itself depends on another private Go
module. The failure happens during typedef generation, before the user
function can run, because codegen resolves the module's Go package without the
SDK auth config.

Add a focused TestPrivateDeps case that builds a Go Dagger module with an
existing go.mod requiring a private GitLab wrapper module. The wrapper lives in
gitlab.com/dagger-modules/private/test/more/dagger-test-modules-private.git/privatewrapper
and depends on the sibling private module privatedeps.

Both fixture modules are versioned with Go submodule tags,
privatewrapper/v0.0.1 and privatedeps/v0.0.1. This keeps the fixture entirely
on the existing private GitLab test repo and avoids relying on two different
pseudo-versions from the same Git repository, which can make the Go command
race its own shallow VCS cache.

Because those submodule tags are normal repository-level Git tags, the shared
GitLab fixture now has more tags than the older SSH tag-listing test expected.
Update that assertion to check that its known tags are present instead of
claiming ownership of the fixture repo's entire tag set.

The new private dependency test mounts the existing SSH agent socket, rewrites
GitLab HTTPS module fetches to SSH, sets GOPRIVATE through dagger.json, runs
dagger call how-cool-is-dagger, and asserts the value returned through the
transitive private dependency. That covers both typedef generation and the
runtime function path.

Signed-off-by: Guillaume de Rouville <[email protected]>
The Go SDK already applies dependency config selectors when generating client
code, but ModuleTypes runs the earlier codegen generate-typedefs pass from a
base container that only has the module source and SDK binary. For modules with
private Go dependencies, that pass invokes the Go toolchain before the
GOPRIVATE, SSH socket, env, and git config selectors have been applied, so
private transitive modules fail to resolve during SDK codegen.

Add moduleDependencyConfigSelectors so the auth and dependency setup derived
from the SDK config is shared by both baseWithCodegen and ModuleTypes.
ModuleTypes applies those selectors before running codegen generate-typedefs,
then removes the socket, env, and git config selectors from the container
snapshot before returning the generated typedefs.

That cleanup preserves the existing behavior where host socket mounts and auth
environment are available to codegen but are not carried forward as part of the
resulting module state. The change is intentionally narrow: it keeps unknown
SDK config validation in one place, preserves the existing selector ordering,
and does not affect non-Go SDK behavior.

Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the fix/private-transitive-go-deps branch from 1021109 to 63ecd03 Compare June 16, 2026 19:19
@grouville
grouville merged commit be7b015 into dagger:main Jun 16, 2026
78 checks passed
marcosnils pushed a commit that referenced this pull request Jun 16, 2026
* test: reproduce private transitive Go deps

Issue #13056 reports that Go SDK codegen fails when a module's existing
go.mod imports a private Go module that itself depends on another private Go
module. The failure happens during typedef generation, before the user
function can run, because codegen resolves the module's Go package without the
SDK auth config.

Add a focused TestPrivateDeps case that builds a Go Dagger module with an
existing go.mod requiring a private GitLab wrapper module. The wrapper lives in
gitlab.com/dagger-modules/private/test/more/dagger-test-modules-private.git/privatewrapper
and depends on the sibling private module privatedeps.

Both fixture modules are versioned with Go submodule tags,
privatewrapper/v0.0.1 and privatedeps/v0.0.1. This keeps the fixture entirely
on the existing private GitLab test repo and avoids relying on two different
pseudo-versions from the same Git repository, which can make the Go command
race its own shallow VCS cache.

Because those submodule tags are normal repository-level Git tags, the shared
GitLab fixture now has more tags than the older SSH tag-listing test expected.
Update that assertion to check that its known tags are present instead of
claiming ownership of the fixture repo's entire tag set.

The new private dependency test mounts the existing SSH agent socket, rewrites
GitLab HTTPS module fetches to SSH, sets GOPRIVATE through dagger.json, runs
dagger call how-cool-is-dagger, and asserts the value returned through the
transitive private dependency. That covers both typedef generation and the
runtime function path.

Signed-off-by: Guillaume de Rouville <[email protected]>

* fix: forward Go auth to typedef generation

The Go SDK already applies dependency config selectors when generating client
code, but ModuleTypes runs the earlier codegen generate-typedefs pass from a
base container that only has the module source and SDK binary. For modules with
private Go dependencies, that pass invokes the Go toolchain before the
GOPRIVATE, SSH socket, env, and git config selectors have been applied, so
private transitive modules fail to resolve during SDK codegen.

Add moduleDependencyConfigSelectors so the auth and dependency setup derived
from the SDK config is shared by both baseWithCodegen and ModuleTypes.
ModuleTypes applies those selectors before running codegen generate-typedefs,
then removes the socket, env, and git config selectors from the container
snapshot before returning the generated typedefs.

That cleanup preserves the existing behavior where host socket mounts and auth
environment are available to codegen but are not carried forward as part of the
resulting module state. The change is intentionally narrow: it keeps unknown
SDK config validation in one place, preserves the existing selector ordering,
and does not affect non-Go SDK behavior.

Signed-off-by: Guillaume de Rouville <[email protected]>

---------

Signed-off-by: Guillaume de Rouville <[email protected]>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.7

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.7 - 2026-06-17

### Changed

- Bump default CNI IP address pool size to reduce address exhaustion under high container concurrency. by @sipsma in dagger/dagger#13394
- Bump Dang to v2.1.1, moving JSON encoding behind the `JSON` namespace (with a deprecated top-level `toJSON`) and picking up constructor scope and nullable input fixes. by @vito in dagger/dagger#13482

### Fixed

- `.env` file handling so non-matching variables are kept as hidden expansion context instead of being dropped, allowing later variables to expand against them. by @marcosnils in dagger/dagger#13490
- Filesync so syncing a re-included file under a gitignored directory (e.g. `foo/` ignored with `!foo/bar.txt`) no longer fails with `no such file or directory`; ignored parent dirs are now created on demand for visible descendants. by @grouville in dagger/dagger#13439
- A concurrent map panic during GC by guarding session client map iteration, preventing fatal `concurrent map iteration and map write` crashes. by @sipsma in dagger/dagger#13474
- Go SDK codegen so SDK auth config is forwarded to typedef generation, allowing modules with private transitive Go dependencies to resolve during codegen. by @grouville in dagger/dagger#13457
- Core enum handling to preserve conventional enum member names. by @shykes in dagger/dagger#13435
- The Apple `container` driver to honor the privileged option by granting all capabilities (`--cap-add ALL`), so the engine can bind-mount `/etc/resolv.conf` on startup with `container` 1.0.0's reduced default capability set. by @eunomie in dagger/dagger#13460
- Dang directive argument resolution so `@cache` (and other directive) arguments resolve against the declaring type's file scope, fixing `FunctionCachePolicy not found in env` errors in multi-file modules. by @vito in dagger/dagger#13455
- The report-mode heartbeat so it waits for its goroutine to exit before final render, avoiding interleaved output. by @kpenfound in dagger/dagger#13425
- Nullable result unwrapping for SDK input so nullable values are passed correctly into SDK functions. by @shykes in dagger/dagger#13401

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

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

🐞 Go SDK codegen fails on private transitive Go module deps since v0.20.4

3 participants