Skip to content

Go SDK generation depends on its own generated output #13605

Open

Description

@shykes

Problem

dagger generate golang cannot regenerate sdk/go/dagger.gen.go if the file is missing, empty, or invalid.

truncate -s 0 sdk/go/dagger.gen.go
dagger generate golang

Codegen imports dagger.io/dagger, which the root go.mod replaces with ./sdk/go. Therefore, codegen requires a valid generated client before it can generate that client.

Solution

Make codegen build independently of its generated output, using either a minimal bootstrap client or a prebuilt codegen binary.

Activity

  1. hitesh0106 commented on Jul 22, 2026

    @hitesh0106

    Hi @shykes @sipsma 👋

    I have submitted a fix for this issue via PR #13713 (using the Bootstrap Client + sdkfs subpackage approach).

    Summary of Fix:

    1. cmd/codegen/internal/bootstrap: Added a minimal, self-contained Dagger client for codegen (Client, Request, Response, ID, Module, TypeDef, etc.) that doesn't depend on dagger.io/dagger.
    2. sdk/go/sdkfs: Created a standalone subpackage embedding go.mod and go.sum without compiling generated client files. Re-exported GoMod/GoSum in sdk/go/fs.go for backward compatibility.
    3. Decoupled Codegen: Replaced all dagger.io/dagger imports in cmd/codegen with bootstrap types.

    Verification:

    All reproduction scenarios (truncated/missing/invalid sdk/go/dagger.gen.go) now build cleanly:

    • truncate -s 0 sdk/go/dagger.gen.go && go build ./cmd/codegen/... ➔ Exit 0
    • rm sdk/go/dagger.gen.go && go build ./cmd/codegen/... ➔ Exit 0

    Feedback and reviews are welcome!

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