{"record":{"id":"e6601f072b3d0e08","repo":"apache/beam","slug":"not-a-float-type-v","errorCode":null,"errorMessage":"not a float type: %v","messagePattern":"not a float type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/coderx/float.go","lineNumber":68,"sourceCode":"\tn := math.Float64frombits(bits.ReverseBytes64(uval.(uint64)))\n\tswitch t.Kind() {\n\tcase reflect.Float64:\n\t\treturn n, nil\n\tcase reflect.Float32:\n\t\treturn float32(n), nil\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unreachable statement: expected a float, got %v\", t))\n\t}\n}\n\n// NewFloat returns a coder for the given float type. It uses the same\n// encoding scheme as the gob package.\nfunc NewFloat(t reflect.Type) (*coder.CustomCoder, error) {\n\tswitch t.Kind() {\n\tcase reflect.Float32, reflect.Float64:\n\t\treturn coder.NewCustomCoder(\"float\", t, encFloat, decFloat)\n\tdefault:\n\t\treturn nil, errors.Errorf(\"not a float type: %v\", t)\n\t}\n}\n","sourceCodeStart":50,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/coderx/float.go#L50-L71","documentation":"NewFloat builds a custom 'float' coder for a Go type. It only supports reflect.Float32 and reflect.Float64; any other kind passed in produces this error. It is an upfront constructor validation, so it fails at coder-creation time, not during data processing.","triggerScenarios":"Calling coderx.NewFloat(t) with a non-float reflect.Type, e.g. NewFloat(reflect.TypeOf(0)) or a struct/slice type, often via inferCoder when a schema field's type isn't float.","commonSituations":"Registering coders for custom types that wrap a float (e.g. type Celsius float64) instead of the underlying float kind; typos in type registration.","solutions":["Pass the actual float type: NewFloat(reflect.TypeOf(float64(0))).","For named types like type Celsius float64, register a coder for the underlying kind or implement a custom coder.","Check inferCoder inputs: ensure the schema element type is float32/float64 before selecting the float coder."],"exampleFix":"// before\nc, err := coderx.NewFloat(reflect.TypeOf(0))\n// after\nc, err := coderx.NewFloat(reflect.TypeOf(float64(0)))","handlingStrategy":"type-guard","validationCode":"// guard before calling NewFloat\nfunc canUseFloatCoder(t reflect.Type) bool {\n    return t != nil && (t.Kind() == reflect.Float32 || t.Kind() == reflect.Float64)\n}","typeGuard":"func isFloatKind(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Float32, reflect.Float64:\n        return true\n    }\n    return false\n}","tryCatchPattern":"c, err := coderx.NewFloat(t)\nif err != nil {\n    return fmt.Errorf(\"cannot build float coder for %s: %w\", t, err)\n}","preventionTips":["Check t.Kind() before selecting a coder constructor.","For named wrapper types (type F float64), register coders on the underlying kind or write a custom coder.","Route coder selection through a single switch on Kind instead of ad-hoc calls."],"tags":["go","apache-beam","coder","type-mismatch","reflect"],"backgroundTag":"incompatible-source-type","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}