{"record":{"id":"ae31a93b28446789","repo":"dagger/dagger","slug":"failed-to-parse-type-reference-w","errorCode":null,"errorMessage":"failed to parse type reference: %w","messagePattern":"failed to parse type reference: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/module_funcs.go","lineNumber":483,"sourceCode":"\t\tdeprecated = &reason\n\t}\n\n\tignore := []string{}\n\tif v, ok := pragmas[\"ignore\"]; ok {\n\t\terr := mapstructure.Decode(v, &ignore)\n\t\tif err != nil {\n\t\t\treturn paramSpec{}, fmt.Errorf(\"ignore pragma %q, must be a valid JSON array: %w\", v, err)\n\t\t}\n\t}\n\n\t// ignore ctx arg for parsing type reference\n\tisContext := paramType.String() == contextTypename\n\tvar typeSpec ParsedType\n\tif !isContext {\n\t\tvar err error\n\t\ttypeSpec, err = ps.parseGoTypeReference(baseType, nil, isPtr)\n\t\tif err != nil {\n\t\t\treturn paramSpec{}, fmt.Errorf(\"failed to parse type reference: %w\", err)\n\t\t}\n\t}\n\n\tname := field.Name()\n\tif name == \"\" && typeSpec != nil {\n\t\t// emulate struct behaviour, where a field with no name gets the type name\n\t\tname = typeSpec.GoType().String()\n\t}\n\n\tvar sourceMap *sourceMap\n\tif astField != nil {\n\t\tsourceMap = ps.sourceMap(astField)\n\t}\n\n\treturn paramSpec{\n\t\tname:            name,\n\t\tparamType:       paramType,\n\t\tsourceMap:       sourceMap,","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/module_funcs.go#L465-L501","documentation":"When resolving a function argument's declared Go type into a Dagger TypeDef, parseGoTypeReference encountered a type the codegen cannot represent (unsupported types like interfaces without names, funcs, chans, or unresolvable external types). The failure is wrapped as 'failed to parse type reference'.","triggerScenarios":"A Dagger function argument typed with something unsupported: an unnamed interface, func, channel, map with unsupported value types, or a type from a package not visited by codegen.","commonSituations":"Using callback-style func args; using types from unanalyzed dependencies; typos causing resolution to unexpected generic/alias types; SDK upgrades adding stricter checks.","solutions":["Change the argument type to a Dagger-supported type (primitives, string, slices, maps, named structs, named interfaces, Directory/File/etc.)","Check the wrapped %w error to identify the unsupported underlying type","Move the type into the module package so codegen can visit and name it"],"exampleFix":"// before\nfunc (m *Mod) Foo(ctx context.Context, cb func(string) error) error\n\n// after\nfunc (m *Mod) Foo(ctx context.Context, message string) error","handlingStrategy":"type-guard","validationCode":"// ensure argument types are Dagger-representable before codegen\n// allowed: string, bool, int, float, slice, map, named struct, named interface, *Directory, *File, *Container...","typeGuard":"func isDaggerSupportedArgType(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Chan, reflect.Func, reflect.UnsafePointer, reflect.Complex64, reflect.Complex128:\n        return false\n    case reflect.Interface:\n        return t.Name() != \"\" // interfaces must be named\n    }\n    return true\n}","tryCatchPattern":"if err := runCodegen(); err != nil {\n    if strings.Contains(err.Error(), \"failed to parse type reference\") {\n        // inspect the wrapped error and replace the unsupported argument type\n    }\n}","preventionTips":["Avoid func/channel/interface{} function arguments","Keep referenced types in the module package so codegen visits them","Read the wrapped cause (%w) for the exact unsupported type"],"tags":["codegen","go","dagger-module","type-reference"],"backgroundTag":"unsupported-function-argument-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"}