{"record":{"id":"4408f822ae93b5b6","repo":"dagger/dagger","slug":"failed-to-parse-field-type-w","errorCode":null,"errorMessage":"failed to parse field type: %w","messagePattern":"failed to parse field type: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/module_objects.go","lineNumber":109,"sourceCode":"\t\treturn nil, fmt.Errorf(\"expected type spec, got %T\", astSpec)\n\t}\n\tastStructType, ok := astTypeSpec.Type.(*ast.StructType)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"expected type spec to be a struct, got %T\", astTypeSpec.Type)\n\t}\n\n\t// Fill out the static fields of the struct (if any)\n\tastFields := unpackASTFields(astStructType.Fields)\n\tfor i := range t.NumFields() {\n\t\tfield := t.Field(i)\n\t\tif !field.Exported() {\n\t\t\tcontinue\n\t\t}\n\n\t\tfieldSpec := &fieldSpec{goType: field.Type()}\n\t\tfieldSpec.typeSpec, err = ps.parseGoTypeReference(fieldSpec.goType, nil, false)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse field type: %w\", err)\n\t\t}\n\n\t\tfieldSpec.goName = field.Name()\n\t\tfieldSpec.name = fieldSpec.goName\n\n\t\t// override the name with the json tag if it was set - otherwise, we\n\t\t// end up asking for a name that we won't unmarshal correctly\n\t\ttag := reflect.StructTag(t.Tag(i))\n\t\tif dt := tag.Get(\"json\"); dt != \"\" {\n\t\t\tnamePart, _, _ := strings.Cut(dt, \",\")\n\t\t\tif namePart == \"-\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif namePart != \"\" {\n\t\t\t\tfieldSpec.name = namePart\n\t\t\t}\n\t\t}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/module_objects.go#L91-L127","documentation":"Wraps a failure from parseGoTypeReference while resolving the type of an exported struct field of a Dagger object. Dagger must map every field to a GraphQL type; if the field's Go type is not representable (unsupported generic, unexported dependency type, channel, func, etc.) the inner error is wrapped as 'failed to parse field type'.","triggerScenarios":"An exported field on a Dagger object struct whose type cannot be mapped to a Dagger type: e.g. `chan int`, `func`, raw generics like `Set[T]`, a type from another module's package that isn't a valid reference, or an unsupported pointer/alias chain.","commonSituations":"Adding convenience fields like sync.Mutex-style handles or context-like values to an object struct; referencing types from dependency modules not exposed in the right package; upgrading Dagger so a previously-tolerated type is rejected.","solutions":["Read the wrapped inner error to see which field/type was rejected.","Change the field to a supported Dagger type (primitive, string-enum, list, another Dagger object, or ID scalar).","Make unsupported fields unexported (lowercase) so they are skipped by codegen.","Use a `json:\"-\"` tag to exclude an exported field from the schema.","For complex types, store them unexported and expose accessor methods instead."],"exampleFix":"// before\ntype Cache struct {\n  Ch chan string\n}\n\n// after\ntype Cache struct {\n  Keys []string\n  ch   chan string // unexported, ignored by codegen\n}","handlingStrategy":"validation","validationCode":"// audit exported fields of Dagger objects for unsupported types:\n//   go vet ./...\n// plus grep for obvious offenders:\n//   grep -R -E '^\\s+[A-Z][A-Za-z]*\\s+(chan|func<|func\\()' --include='*.go' .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict exported fields to Dagger-supported types (primitives, lists, objects, IDs).","Keep non-schema fields unexported or tagged `json:\"-\"`.","Expose complex library types via accessor methods, not fields."],"tags":["dagger","codegen","go","field-type"],"backgroundTag":"codegen-unsupported-type-declaration","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"}