{"record":{"id":"16e8a02b015a4d9b","repo":"dagger/dagger","slug":"failed-to-generate-underlying-impl-type-code-w","errorCode":null,"errorMessage":"failed to generate underlying impl type code: %w","messagePattern":"failed to generate underlying impl type code: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/module_interfaces.go","lineNumber":614,"sourceCode":"\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\treturn results, nil\n\t\t\t*/\n\n\t\t\ts.Id(\"q\").Op(\"=\").Id(\"q\").Dot(\"Select\").Call(Lit(\"id\")).Line()\n\t\t\ts.Var().Id(\"idResults\").Index().Struct(Id(\"Id\").Id(\"dagger.ID\")).Line()\n\t\t\ts.Id(\"q\").Op(\"=\").Id(\"q\").Dot(\"Bind\").Call(Op(\"&\").Id(\"idResults\")).Line()\n\n\t\t\ts.Id(\"err\").Op(\":=\").Id(\"q\").Dot(\"Execute\").Call(Id(\"ctx\")).Line()\n\t\t\ts.If(Id(\"err\").Op(\"!=\").Nil()).Block(Return(Nil(), Id(\"err\"))).Line()\n\n\t\t\tunderlyingReturnTypeCode, err := spec.concreteMethodSigTypeCode(returnType.underlying)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to generate underlying return type code: %w\", err)\n\t\t\t}\n\t\t\tunderlyingImplTypeCode, err := spec.concreteMethodImplTypeCode(returnType.underlying)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to generate underlying impl type code: %w\", err)\n\t\t\t}\n\t\t\ts.Var().Id(\"results\").Index().Add(underlyingReturnTypeCode).Line()\n\t\t\ts.For(List(Id(\"_\"), Id(\"idResult\")).Op(\":=\").Range().Id(\"idResults\")).BlockFunc(func(g *Group) {\n\t\t\t\tg.Id(\"id\").Op(\":=\").Id(\"idResult\").Dot(\"Id\")\n\t\t\t\tquery := Id(\"r\").Dot(\"query\").Dot(\"Root\").Call().Dot(\"Select\").Call(Lit(\"node\")).Dot(\"Arg\").Call(Lit(\"id\"), Id(\"id\")).Dot(\"InlineFragment\").Call(Lit(gqlSchemaName(underlyingReturnType.Name(), underlyingReturnType.ModuleName())))\n\t\t\t\tg.Id(\"results\").Op(\"=\").Append(Id(\"results\"), Params(Op(\"&\").Add(underlyingImplTypeCode).Values()).Dot(\"WithGraphQLQuery\").Call(query))\n\t\t\t}).Line()\n\n\t\t\ts.Return(Id(\"results\"), Nil())\n\n\t\tcase *parsedPrimitiveType, nil:\n\t\t\t/*\n\t\t\t\tNeed to return the slice of the primitive, e.g.:\n\n\t\t\t\t\tvar response []string\n\t\t\t\t\tq = q.Bind(&response)\n\t\t\t\t\treturn response, q.Execute(ctx)\n\t\t\t*/","sourceCodeStart":596,"sourceCodeEnd":632,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/module_interfaces.go#L596-L632","documentation":"Emitted by the Dagger Go SDK code generator while building the body for a method that returns a slice of objects/interfaces. After the signature type code succeeds, `concreteMethodImplTypeCode` must render the concrete implementation struct type (e.g. &dagger.Directory{...}) for each slice element; failure there is wrapped as \"failed to generate underlying impl type code: %w\". It indicates the generator cannot produce the impl struct for the underlying element type.","triggerScenarios":"Codegen over a module function returning []Iface/[]Object where the element type's implementation struct cannot be generated — e.g. the named type references a module or object not present in the current introspection input.","commonSituations":"Cross-module types whose defining module wasn't codegen'd; renames of objects between core/SDK versions; stale generated code referencing removed types.","solutions":["Inspect the wrapped inner error to identify the failing element type.","Regenerate the SDK with an up-to-date dagger CLI (`dagger develop`) to refresh templates and type specs.","Ensure the module providing the element type is a dependency and is itself generated/current.","Fall back to returning element IDs ([]DirectoryID) if the object type cannot be supported."],"exampleFix":"// before\nfunc (m *Mod) All(ctx context.Context) ([]MissingType, error)\n// after: re-add the dependency module or use IDs\nfunc (m *Mod) All(ctx context.Context) ([]DirectoryID, error)","handlingStrategy":"validation","validationCode":"// check the dependency module defining the element type exists and is current\nif _, err := os.Stat(\"dagger.json\"); err == nil {\n    var cfg map[string]any\n    json.NewDecoder(mustOpen(\"dagger.json\")).Decode(&cfg)\n    for dep := range cfg[\"dependencies\"].(map[string]any) {\n        if _, err := os.Stat(filepath.Join(dep, \"dagger.json\")); err != nil {\n            log.Fatalf(\"dependency module %s missing; run `dagger develop` in it first\", dep)\n        }\n    }\n}","typeGuard":"func hasImplType(t ParsedType) bool {\n    if named, ok := t.(NamedParsedType); ok {\n        return named.Name() != \"\" // impl structs are generated only for named types\n    }\n    return false\n}","tryCatchPattern":"underlyingImplTypeCode, err := spec.concreteMethodImplTypeCode(returnType.underlying)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to generate underlying impl type code for %s: %w\", returnType.underlying.Name(), err)\n}","preventionTips":["Always `dagger develop` dependency modules before the consuming module.","Commit generated SDK code so stale-type drift is visible in diffs.","Avoid referencing types from modules not declared in dagger.json dependencies.","Upgrade CLI+SDK atomically."],"tags":["codegen","go-sdk","dagger"],"backgroundTag":"codegen-unsupported-type","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"}