Repository navigation
codegen/go: allow imports without a session - #14880
Merged
Merged
Conversation
Generated Go bindings read session settings at package load time. A test that only imports these bindings fails before any test can run. This forces the test runner to open a session for tests that never use Dagger. Read the settings on the first API request. Share one client between normal queries and handles decoded from JSON. Return an error for missing or invalid settings, and allow a later request to try again. Keep the client after the first successful configuration check. The regression test compiles both generated packages without a session. It checks handles created before session setup, configuration errors, concurrent requests, and authentication. The test fails with the original package initialization panic on the previous templates. Validation: GOFLAGS=-race go test ./cmd/codegen/generator/go/... Companion change: dagger/go#83 Signed-off-by: Tibor Vass <[email protected]>
tiborvass
force-pushed
the
codex/import-safe-legacy-codegen
branch
from
October 27, 2026 14:21
42e0e98 to
077d57f
Compare
tiborvass
added a commit
to dagger/go
that referenced
this pull request
Oct 27, 2026
The test runner opens a Dagger session for every test command. Generated bindings require this at package load time, even when the tests never call Dagger. The same wrapper also starts sessions for tests that do not import those bindings. Generate the gobuild bindings with the deferred session setup from dagger/dagger#14880. Run otelgotest without the session wrapper. Keep access to the mounted CLI so tests can start a session when they need one. Update the nesting test to open its own session and check workspace access. The engine used for generation must include dagger/dagger#14880. The released engine still writes the previous initializers, so the generated-file check fails until that dependency is available. Validation: gobuild tests passed without session settings. The single-module, skips-non-modules, tests-collection, and binary checks passed. Scanner tests also passed without session settings and with an invalid CLI path. Depends on: dagger/dagger#14880 Signed-off-by: Tibor Vass <[email protected]>
kpenfound
approved these changes
Oct 28, 2026
tiborvass
added a commit
to dagger/go
that referenced
this pull request
Nov 2, 2026
The test runner opens a Dagger session for every test command. Generated bindings require this at package load time, even when the tests never call Dagger. The same wrapper also starts sessions for tests that do not import those bindings. Generate the gobuild bindings with the deferred session setup from dagger/dagger#14880. Run otelgotest without the session wrapper. Keep access to the mounted CLI so tests can start a session when they need one. Update the nesting test to open its own session and check workspace access. The engine used for generation must include dagger/dagger#14880. The released engine still writes the previous initializers, so the generated-file check fails until that dependency is available. Validation: gobuild tests passed without session settings. The single-module, skips-non-modules, tests-collection, and binary checks passed. Scanner tests also passed without session settings and with an invalid CLI path. Depends on: dagger/dagger#14880 Signed-off-by: Tibor Vass <[email protected]>
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.
Generated Go bindings read session settings at package load time. A test
that only imports these bindings fails before any test can run. This
forces the test runner to open a session for tests that never use
Dagger.
Read session settings on the first API request. Imports, query
construction, and JSON decoding can then work without a session. Missing
or invalid settings return an error. A later request can try again after
session setup.
The connect layer and the core package share one client. A mutex
protects client setup. Network requests run outside the lock.
Companion PR: dagger/go#83
Validation:
GOFLAGS=-race go test ./cmd/codegen/generator/go/...passed.session.
errors.