{"record":{"id":"afa5a10db8c3eda3","repo":"dagger/dagger","slug":"failed-to-generate-slice-field-type-code-w","errorCode":null,"errorMessage":"failed to generate slice field type code: %w","messagePattern":"failed to generate slice field type code: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/module_objects.go","lineNumber":484,"sourceCode":"\t\t\t}\n\n\t\t\ts.Id(typeSpec.GoType().String())\n\t\t}\n\n\tcase *parsedEnumTypeReference:\n\t\tif typeSpec.isPtr {\n\t\t\ts.Op(\"*\")\n\t\t}\n\t\tif typeSpec.moduleName == \"\" {\n\t\t\ts.Id(\"dagger.\" + typeSpec.name)\n\t\t} else {\n\t\t\ts.Id(typeSpec.name)\n\t\t}\n\n\tcase *parsedSliceType:\n\t\tfieldTypeCode, err := spec.concreteFieldTypeCode(typeSpec.underlying)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to generate slice field type code: %w\", err)\n\t\t}\n\t\ts.Index().Add(fieldTypeCode)\n\n\tcase *parsedObjectTypeReference:\n\t\tif typeSpec.isPtr {\n\t\t\ts.Op(\"*\")\n\t\t}\n\t\ts.Id(typeName(typeSpec))\n\n\tcase *parsedIfaceTypeReference:\n\t\ts.Op(\"*\").Id(concreteIfaceImplName(typeSpec))\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported concrete field type %T\", typeSpec)\n\t}\n\n\treturn s, nil\n}","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/module_objects.go#L466-L502","documentation":"During Dagger module Go codegen, when generating the concrete struct type for a slice field (e.g. []Foo or []*Foo), the codegen recursively generates the field type code for the slice's element type. If generating that element type code fails, the failure is wrapped with \"failed to generate slice field type code\". This is a wrapper error: the real cause is in the element type itself.","triggerScenarios":"Running dagger develop/codegen on a module whose object has a slice field whose element type causes concreteFieldTypeCode to hit its default branch (an unsupported ParsedType implementation) or another nested failure (e.g. a nested slice of an unsupported type).","commonSituations":"A dagger.ObjectStruct field like []SomeIface or [][]SomeUnsupportedType where the element resolves to a ParsedType variant the concrete-struct generator doesn't handle; usually encountered right after adding a new field type to a module or after a Dagger SDK version upgrade changed the parsed type set.","solutions":["Read the wrapped cause (%w) below this message in the codegen output to find the actual unsupported element type","Simplify the field's element type to a supported one: primitive, enum, named object struct, or named interface","Ensure slice elements are named types (avoid anonymous structs or maps as element types)","Update the Dagger CLI/SDK, as newer versions support more concrete field types"],"exampleFix":"// before (module code)\nField []map[string]string\n// after\nField []string","handlingStrategy":"validation","validationCode":"// before running codegen, check slice fields only contain supported named types\ntype checker struct{ err error }\nfunc (c *checker) Visit(n ast.Node) ast.Visitor {\n\tif ft, ok := n.(*ast.Field); ok && ft.Type != nil {\n\t\tif !supportedFieldType(ft.Type) {\n\t\t\tc.err = fmt.Errorf(\"slice field element %s is not a supported named type\", ft.Type)\n\t\t}\n\t}\n\treturn c\n}","typeGuard":"func isSupportedElemType(t ast.Expr) bool {\n\tswitch e := t.(type) {\n\tcase *ast.Ident: return true\n\tcase *ast.StarExpr: return isSupportedElemType(e.X)\n\tcase *ast.ArrayType: return isSupportedElemType(e.Elt)\n\tdefault: return false\n\t}\n}","tryCatchPattern":"if err := generateModule(); err != nil {\n\tvar wrapped interface{ Unwrap() error }\n\tif errors.As(err, &target) { log.Fatalf(\"codegen: root cause: %v\", errors.Unwrap(err)) }\n}","preventionTips":["Use named struct/interface/enum types as slice elements, never anonymous or map types","Keep dagger CLI and dagger.io/dagger SDK versions aligned","Run dagger develop locally before CI so codegen failures surface early","Read errors.Unwrap chains — this message always wraps the real cause"],"tags":["codegen","go","dagger","slice"],"backgroundTag":"unsupported-codegen-field-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"}