{"record":{"id":"f48c7ff49e38ecc9","repo":"apache/beam","slug":"t-isn-t-a-supported-decoder-function-type-passed-with-v","errorCode":null,"errorMessage":"%T isn't a supported decoder function type (passed with %v), currently expecting %T","messagePattern":"%T isn't a supported decoder function type \\(passed with (.+?)\\), currently expecting %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/coder/row_decoder.go","lineNumber":53,"sourceCode":"\tRequireAllFieldsExported bool\n}\n\ntype decoderProvider = func(reflect.Type) (func(io.Reader) (any, error), error)\n\n// Register accepts a provider to decode schema encoded values\n// of that type.\n//\n// When decoding values, decoder functions produced by this builder will\n// first check for exact type matches, then interfaces implemented by\n// the type in recency order of registration, and then finally the\n// default Beam Schema encoding behavior.\n//\n// TODO(BEAM-9615): Add final factory types. This interface is subject to change.\n// Currently f must be a function  func(reflect.Type) (func(io.Reader) (any, error), error)\nfunc (b *RowDecoderBuilder) Register(rt reflect.Type, f any) {\n\tfd, ok := f.(decoderProvider)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"%T isn't a supported decoder function type (passed with %v), currently expecting %T\", f, rt, (decoderProvider)(nil)))\n\t}\n\n\tif rt.Kind() == reflect.Interface && rt.NumMethod() == 0 {\n\t\tpanic(fmt.Sprintf(\"interface type %v must have methods\", rt))\n\t}\n\n\tif b.allFuncs == nil {\n\t\tb.allFuncs = make(map[reflect.Type]decoderProvider)\n\t}\n\tb.allFuncs[rt] = fd\n\tif rt.Kind() == reflect.Interface {\n\t\tb.ifaceFuncs = append(b.ifaceFuncs, rt)\n\t}\n}\n\n// Build constructs a Beam Schema coder for the given type, using any providers registered for\n// itself or it's fields.\nfunc (b *RowDecoderBuilder) Build(rt reflect.Type) (func(io.Reader) (any, error), error) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/coder/row_decoder.go#L35-L71","documentation":"RowDecoderBuilder.Register panics when the supplied f is not a decoderProvider, i.e. not the exact signature func(reflect.Type) (func(io.Reader) (any, error), error). The builder stores custom decoder factories keyed by reflect.Type and cannot accept functions of any other shape.","triggerScenarios":"Calling row_decoder_builder.Register(rt, f) where f is a plain decoder func, a closure with the wrong parameter/return types, a method value, or any non-function value.","commonSituations":"Registering a decoder written for an older Beam API whose signature changed (BEAM-9615 factory types still in flux); passing a partially-applied helper with mismatched types; typos in the return types (io.Reader vs io.ReadCloser).","solutions":["Change f to exactly func(reflect.Type) (func(io.Reader) (any, error), error)","Wrap the existing decoder in an adapter closure matching decoderProvider","Check the Beam version's decoderProvider definition and match it"],"exampleFix":"// before\nb.Register(reflect.TypeOf(Foo{}), func(r io.Reader) (any, error) { ... })\n// after\nb.Register(reflect.TypeOf(Foo{}), func(rt reflect.Type) (func(io.Reader) (any, error), error) {\n\treturn func(r io.Reader) (any, error) { ... }, nil\n})","handlingStrategy":"validation","validationCode":"// compile-time shape check\nvar _ rowcoder.DecoderProvider = myDecoderProviderFunc","typeGuard":"if _, ok := f.(func(reflect.Type) (func(io.Reader) (any, error), error)); !ok {\n\treturn fmt.Errorf(\"f must be a decoderProvider factory\")\n}","tryCatchPattern":"func safeRegister(b *rowcoder.RowDecoderBuilder, rt reflect.Type, f any) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"register decoder: %v\", r)\n\t\t}\n\t}()\n\tb.Register(rt, f)\n\treturn nil\n}","preventionTips":["Copy the decoderProvider signature from the Beam source when writing custom decoders","Pin and review Beam version changes around row coder factories (BEAM-9615)","Add a compile-time assertion that your function satisfies decoderProvider"],"tags":["go","beam","reflection","type-mismatch"],"backgroundTag":"type-mismatch","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"}