{"record":{"id":"345fd114bb397290","repo":"apache/beam","slug":"unable-to-convert-logicaltype-v-using-provider-for-v-schema","errorCode":null,"errorMessage":"unable to convert LogicalType[%v] using provider for %v schema field","messagePattern":"unable to convert LogicalType\\[(.+?)\\] using provider for (.+?) schema field","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":348,"sourceCode":"func (r *Registry) logicalTypeToFieldType(t reflect.Type) (*pipepb.FieldType, string, error) {\n\t// Check if a logical type was registered that matches this struct type directly\n\t// and if so, extract the schema from it for use.\n\tif lID, ok := r.logicalTypeIdentifiers[t]; ok {\n\t\tlt := r.logicalTypes[lID]\n\t\tftype, err := r.reflectTypeToFieldType(lt.StorageType())\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.Wrapf(err, \"unable to convert LogicalType[%v]'s storage type %v for Go type of %v to a schema\", lID, lt.StorageType(), lt.GoType())\n\t\t}\n\t\treturn ftype, lID, nil\n\t}\n\tfor _, lti := range r.logicalTypeInterfaces {\n\t\tif !t.Implements(lti) {\n\t\t\tcontinue\n\t\t}\n\t\tp := r.logicalTypeProviders[lti]\n\t\tst, err := p(t)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.Wrapf(err, \"unable to convert LogicalType[%v] using provider for %v schema field\", t, lti)\n\t\t}\n\t\tif st == nil {\n\t\t\tcontinue\n\t\t}\n\t\tftype, err := r.reflectTypeToFieldType(st)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.Wrapf(err, \"unable to convert LogicalType[%v]'s storage type %v for Go type of %v to a schema\", \"interface\", st, t)\n\t\t}\n\t\treturn ftype, t.String(), nil\n\t}\n\treturn nil, \"\", nil\n}\n\n// fromType handles if the initial type is a pointer or not WRT lookups against\n// registered types and then delegates to structToSchema for most of the conversion.\n// For determinism in schema IDs, regardless of whther the original type is a pointer or not,\n// both variants are cached for latter reuse.\nfunc (r *Registry) fromType(ot reflect.Type) (*pipepb.Schema, error) {","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L330-L366","documentation":"Raised in Registry.logicalTypeToFieldType when a type t implements a registered logical type interface and that interface's provider function p(t) returns an error. The wrap preserves both the Go type and the interface type, indicating the provider could not produce a storage type for t.","triggerScenarios":"Converting a struct field whose type implements a registered logical type interface where the provider callback errors — typically because the provider rejects that concrete type or its values.","commonSituations":"Types implementing a logical-type interface incompletely; provider logic asserting value constraints (invalid dates, bad decimal scale) that fail at schema-conversion time during pipeline graph building.","solutions":["Read the wrapped provider error — it is produced by the provider function.","Fix the type/value so it satisfies the provider's constraints.","If it's your provider, return a valid storage type or nil (meaning 'not handled') instead of an error.","Register a direct LogicalType for the concrete type instead of relying on the interface provider."],"exampleFix":"// before\np := func(t reflect.Type) (reflect.Type, error) { return nil, fmt.Errorf(\"unsupported %v\", t) }\n// after\np := func(t reflect.Type) (reflect.Type, error) {\n    if valid(t) { return reflect.TypeOf([]byte{}), nil }\n    return nil, nil // not handled, try next provider\n}","handlingStrategy":"try-catch","validationCode":"if _, err := myProvider(reflect.TypeOf(myVal)); err != nil {\n    return fmt.Errorf(\"provider rejects type: %w\", err)\n}","typeGuard":"func implementsLogicalInterface(t reflect.Type, iface reflect.Type) bool { return t.Implements(iface) }","tryCatchPattern":"schm, err := reg.FromType(t)\nif err != nil && strings.Contains(err.Error(), \"using provider\") {\n    return nil, fmt.Errorf(\"provider failed for %v: %w\", reflect.TypeOf(t), err)\n}","preventionTips":["Return nil (not an error) from providers when the type is not handled.","Keep provider constraints simple and value-independent.","Register direct logical types for known-concrete types.","Test providers against all concrete types implementing the interface."],"tags":["go","schema","logical-type","provider"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}