Skip to content

Go SDK codegen's 'go get -u' + 'go mod tidy' makes module builds (incl. built-in python-sdk runtime) non-reproducible and fragile to upstream dependency regressions #14462

Open

Description

@gregoryboue

Summary

Modules using the Go SDK ("sdk": {"source": "go"} in dagger.json) — including Dagger's own built-in python-sdk runtime, whose Go runtime is itself built via the Go SDK codegen pipeline — are built against unpinned, floating dependency versions, because the Go SDK codegen's post-generation commands run go get -u followed by go mod tidy:

// cmd/codegen/generator/go/generate_module.go
genSt.PostCommands = append(genSt.PostCommands,
    exec.Command("go", "get", "-u", daggerImportPath+"@"+g.Config.ModuleConfig.LibVersion))
...
genSt.PostCommands = append(genSt.PostCommands,
    exec.Command("go", "mod", "tidy"),
)

go get -u re-resolves the entire transitive dependency graph to the latest available versions, ignoring whatever is committed in go.sum. This means every module build is implicitly exposed to any breaking change published upstream by a transitive dependency, at any time, with zero warning and zero way for module authors to pin against it.

Impact observed

On 2026-10-02, go.opentelemetry.io/otel v1.47.0 was published upstream with a self-import cycle bug (reported separately: open-telemetry/opentelemetry-go#9071). Because the engine-builtin python-sdk module's runtime is a Go program built through this exact codegen path, and transitively depends on go.opentelemetry.io/otel (via github.com/dagger/otel-go), every single Dagger module relying on the Python SDK started failing fleet-wide within hours of the otel release, with no change on our end:

failed to get sdk object for sdk module python-sdk: call constructor: exit code: 1

Full build error:

package python-sdk
	imports github.com/dagger/otel-go from dagger.gen.go
	imports go.opentelemetry.io/otel from init.go
	imports go.opentelemetry.io/otel/internal/global from handler.go
	imports go.opentelemetry.io/otel/log from logger.go
	imports go.opentelemetry.io/otel/internal/global from keyvalue.go: import cycle not allowed

This affected engine v0.20.8 (and would equally affect v0.20.6, since the go get -u behavior is identical — it's not an engine-version-specific regression, it's a build-time dependency resolution issue).

Confusing symptom: apparent "intermittency"

Builds that ran before the upstream otel release (or on engine pods with a module-proxy cache still returning a pre-regression "latest") succeeded; builds on freshly-scheduled pods after the otel release failed deterministically (confirmed 4/4 in manual reproduction via dagger functions). This made the issue initially look like a flaky/intermittent engine problem, when it was actually a fully deterministic point-in-time dependency resolution issue.

Why this is risky

  • sdk/go/go.mod (the dagger.io/dagger library itself) pins go.opentelemetry.io/otel to a fixed version in its own go.mod/go.sum.
  • But go get -u on a user's or built-in module's go.mod bypasses this entirely, upgrading to whatever is "latest" on the Go module proxy at build time for every transitive dependency, not just dagger.io/dagger.
  • This makes Go-SDK-based Dagger module builds fundamentally non-reproducible and non-pinned, unlike declared/locked dependencies in virtually every other package ecosystem.
  • Built-in SDKs (like python-sdk, whose own runtime is written in Go and built via this same path) are not supposed to be subject to "whatever the user's floating deps resolve to today" — they ship with the engine and should build deterministically regardless of what's published upstream on a given day.

Suggested fixes

  1. Avoid go get -u (unbounded upgrade) in the codegen post-commands; use go get <path>@<version> for the specific pinned version only, and let go mod tidy fill in the rest from the existing go.sum without force-upgrading already-pinned transitive dependencies.
  2. For engine-builtin SDK runtimes specifically (python-sdk, typescript-sdk's embedded Go bits, etc.), avoid routing their own build through the generic "user module" Go SDK codegen path that assumes floating/latest dependency resolution — these should build from a fully vendored/locked dependency set shipped with the engine release.
  3. At minimum, document this behavior clearly so module/SDK maintainers understand that Go SDK-based builds are not reproducible across time, and consider adding a flag/config to disable the -u upgrade behavior.

Environment

Activity

  1. gregoryboue commented on Oct 2, 2026

    @gregoryboue
    Author

    Correction to this report, and a hard constraint this surfaces

    Two updates after further investigation.

    1. The otel side is not a bug. I had filed open-telemetry/opentelemetry-go#9071 against otel v1.47.0; it was closed as not planned, correctly. otel v1.47.0 requires otel/log v1.47.0, and the cycle only appears because this repo's replace directives force otel/log back down to v0.16.0 — below what the release requires, into code the otel team considers experimental. The maintainer also pointed out that a minimum require would not help, since a replace overrides it. That's right. So the remaining issue is entirely on Dagger's side, which is this issue.

    2. The go get -u + pinned-replace combination is now a hard contradiction, not merely fragile. This is the part I'd like to flag, because the obvious fix does not work.

    The runtime go.mod files (84 of them in v0.20.8, including sdk/python/runtime/go.mod) carry:

    replace go.opentelemetry.io/otel/log     => go.opentelemetry.io/otel/log v0.16.0
    replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.16.0
    replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => ... v0.16.0
    replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => ... v0.16.0
    

    while codegen runs go get -u, which floats otel to latest. Those two settings pull in opposite directions, so the collision was only a matter of time; v1.47.0 merely triggered it.

    Results

    All runs use the real dependency set (github.com/dagger/otel-go + the four replace directives above), go get -u + go mod tidy, go1.26.8, linux/amd64:

    go.mod configuration Result
    replace → v0.16.0 (current, otel floats to v1.47.0) FAIL — import cycle not allowed
    replace → v0.21.0 (bump the pin) FAIL — undefined: log.KeyValue in dagger/otel-go
    no replace at all (the suggested fix) FAIL — undefined: log.KeyValue in dagger/otel-go
    replace → v0.16.0 and otel capped at v1.46.0 BUILD OK

    So simply dropping the replace directives is not a viable fix today:

    # github.com/dagger/otel-go
    /go/pkg/mod/github.com/dagger/[email protected]/logging.go:47:63: undefined: log.KeyValue
    

    Why

    log.KeyValue was removed in otel/log v0.21.0:

    otel/log log.KeyValue back-edge into otel/internal/global
    ≤ v0.20.0 present present → cycles against otel v1.47.0
    ≥ v0.21.0 removed absent

    github.com/dagger/otel-go (both published versions, v1.41.0 and v1.43.0) uses log.KeyValue in logging.go, so it requires otel/log ≤ v0.20.0 — precisely the range that cycles against otel ≥ v1.47.0. No version of otel/log satisfies both constraints simultaneously. The two requirements are mutually exclusive, so there is no go.mod-only fix.

    What this means

    The only configuration that builds is capping otel at v1.46.0. That is what we had to do operationally: a version exclusion on our Artifactory Go proxy, masking otel v1.47.0 so MVS falls back to v1.46.0. It works, but it is a version freeze — it blocks all future otel upgrades, and it is not something every Dagger user can implement.

    Worth noting that main still carries replace ... => go.opentelemetry.io/otel/log v0.16.0 alongside otel v1.44.0, so this is not resolved upstream. Any user whose codegen floats otel past v1.46.0 hits it.

    A real fix appears to need github.com/dagger/otel-go updated off the removed log.KeyValue API first, after which the replace pins can be dropped or raised. Until then, every Go-SDK module build is one go get -u away from this failure.

    Suggestion

    Independently of the otel specifics, the underlying problem is that go get -u makes module builds non-reproducible: an upstream publish can break every module build fleet-wide, as happened here within hours of the v1.47.0 release, with no change on the user side. Dropping -u (resolving only the dagger.io/dagger bump explicitly) would keep the committed go.sum authoritative and make this class of incident impossible — which seems preferable to relying on the dependency graph staying coincidentally compatible.

    Happy to provide the full reproducers for any row in the table above.

  2. gregoryboue commented on Oct 2, 2026

    @gregoryboue
    Author

    Correction: this is already fixed upstream — apologies for the noise

    I need to correct my previous comment. I stated this was unresolved on main; that was wrong. I had checked sdk/python/runtime/go.mod (where the replace directives are still present) without checking the codegen itself, and drew the wrong conclusion.

    The -u flag is gone:

    // v0.21.0 and earlier
    exec.Command("go", "get", "-u", daggerImportPath+"@"+g.Config.ModuleConfig.LibVersion)
    
    // v0.21.1 and later
    exec.Command("go", "get", daggerImportPath+"@"+g.Config.ModuleConfig.LibVersion)

    Fixed by #13244 ("fix(go): avoid transitive upgrades during module generation", merged 2026-05-28), which is exactly the change I was asking for in this issue. I should have found it before filing.

    Verified boundary across released tags:

    Engine version codegen post-command build with the real dep set
    v0.20.6, v0.20.8, v0.21.0 go get -u FAIL — import cycle not allowed
    v0.21.1 … v0.21.10 go get BUILD OK

    Reproducing with the actual sdk/python/runtime/go.mod from v0.21.10 (github.com/dagger/otel-go v1.41.0 plus the four otel/log v0.16.0 replace directives), running go get dagger.io/dagger@latest + go mod tidy without -u:

    go.opentelemetry.io/otel v1.44.0
    go.opentelemetry.io/otel/log v0.17.0 => go.opentelemetry.io/otel/log v0.16.0
    BUILD OK
    

    otel correctly stays at v1.44.0 instead of floating to v1.47.0, so the pinned replace directives are no longer in conflict and the cycle never materialises.

    This also corrects the conclusion of my earlier comment: the replace pins are not the root cause and do not need to be removed. The -u was. The claim that "no version of otel/log satisfies both constraints" still holds as a static fact about otel/log ≥ v0.21.0 dropping log.KeyValue (which dagger/otel-go uses), but it is not an operational problem, because nothing pushes otel past v1.46.0 once transitive upgrades are no longer forced. Migrating dagger/otel-go off log.KeyValue is therefore not urgent.

    We were hit because we are pinned to engine v0.20.8, which predates the fix. That is on us. The resolution is to upgrade, not to patch anything.

    Feel free to close this issue as already resolved by #13244. Thanks for the fix, and sorry for not locating it before opening this.

    One small suggestion, take it or leave it: since the affected v0.20.x line is still in use, a note in the v0.21.1 release notes or the troubleshooting docs explicitly linking the symptom to the fix could help. The user-visible failure is opaque —

    failed to get sdk object for sdk module python-sdk: call constructor: exit code: 1
    

    — and gives no hint that it stems from forced transitive upgrades, nor that upgrading the engine resolves it. It cost us a full day of diagnosis before identifying the mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions