{"record":{"id":"6f4f3afc2357db45","repo":"dagger/dagger","slug":"failed-to-generate-concrete-struct-code-for-s-w","errorCode":null,"errorMessage":"failed to generate concrete struct code for %s: %w","messagePattern":"failed to generate concrete struct code for (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/modules.go","lineNumber":173,"sourceCode":"\t\t\t\timplCode, err := objTypeSpec.ImplementationCode()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to generate json method code for %s: %w\", obj.Name(), err)\n\t\t\t\t}\n\t\t\t\timplementationCode.Add(implCode).Line()\n\n\t\t\t\tobjTypeDefCode, err := objTypeSpec.TypeDefCode()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to generate type def code for %s: %w\", obj.Name(), err)\n\t\t\t\t}\n\t\t\t\tcreateMod = dotLine(createMod, \"WithObject\").Call(Add(Line(), objTypeDefCode))\n\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tIfaceVisitor: func(ps *parseState, named *types.Named, obj *types.TypeName, ifaceTypeSpec *parsedIfaceType, iface *types.Interface) error {\n\t\t\t\t// Add the iface to the module\n\t\t\t\timplCode, err := ifaceTypeSpec.ImplementationCode()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to generate concrete struct code for %s: %w\", obj.Name(), err)\n\t\t\t\t}\n\t\t\t\timplementationCode.Add(implCode).Line()\n\n\t\t\t\tifaceTypeDefCode, err := ifaceTypeSpec.TypeDefCode()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to generate type def code for %s: %w\", obj.Name(), err)\n\t\t\t\t}\n\t\t\t\tcreateMod = dotLine(createMod, \"WithInterface\").Call(Add(Line(), ifaceTypeDefCode))\n\n\t\t\t\treturn nil\n\t\t\t},\n\t\t\tEnumVisitor: func(ps *parseState, named *types.Named, obj *types.TypeName, enumTypeSpec *parsedEnumType, enum *types.Basic) error {\n\t\t\t\t// Add the enum to the module\n\t\t\t\timplCode, err := enumTypeSpec.ImplementationCode()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to generate enum code for %s: %w\", obj.Name(), err)\n\t\t\t\t}\n\t\t\t\timplementationCode.Add(implCode).Line()","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/modules.go#L155-L191","documentation":"Wrapping error from the IfaceVisitor in moduleMainSrc: when a module exposes a named interface type, codegen generates a concrete struct implementing that interface; generating that concrete struct's ImplementationCode failed. The failing interface's name is included and the underlying cause is preserved with %w.","triggerScenarios":"ifaceTypeSpec.ImplementationCode() errors while emitting the concrete struct for a module interface — typically because an interface method has parameters/returns of types the codegen cannot model, or a referenced subtype fails to parse.","commonSituations":"Interfaces with methods taking/returning unsupported Go types (funcs, channels, maps), interfaces referencing types from a dependency module that failed to load, or hand-edited generated code drifting from user interfaces.","solutions":["Inspect the wrapped cause to find which interface method or referenced type broke generation.","Restrict interface methods to supported Dagger types for all parameters and return values.","Regenerate with `dagger develop`, ensure dependent modules load correctly, and update the Dagger CLI/SDK if the input code is valid."],"exampleFix":"// before\ntype Publisher interface {\n\tSubscribe(cb func(string)) error\n}\n\n// after\ntype Publisher interface {\n\tPublish(msg string) error\n}","handlingStrategy":"try-catch","validationCode":"// Ensure all interface methods use supported param/return types before codegen.\nfunc validateIfaceMethods(t reflect.Type) error {\n\tfor i := 0; i < t.NumMethod(); i++ {\n\t\tm := t.Method(i)\n\t\tfor j := 0; j < m.Type.NumIn(); j++ {\n\t\t\tif k := m.Type.In(j).Kind(); k == reflect.Func || k == reflect.Chan || k == reflect.Map {\n\t\t\t\treturn fmt.Errorf(\"method %s arg %d has unsupported kind %v\", m.Name, j, k)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := codegen(); err != nil && strings.Contains(err.Error(), \"failed to generate concrete struct code\") {\n\tlog.Fatalf(\"interface codegen failed: %v\", errors.Unwrap(err))\n}","preventionTips":["Design module interfaces with only supported Dagger types in method signatures.","Keep dependent modules resolvable and their generated code current.","Regenerate dagger.gen.go after any interface change; never edit generated concrete structs by hand."],"tags":["go","codegen","dagger-module","interface"],"backgroundTag":"codegen-implementation-failure","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}