{"record":{"id":"76bd876388efad41","repo":"apache/beam","slug":"invalid-float-encoding-for-v","errorCode":null,"errorMessage":"invalid float encoding for: %v","messagePattern":"invalid float encoding for: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/coderx/float.go","lineNumber":47,"sourceCode":"\nfunc encFloat(v typex.T) []byte {\n\tvar val float64\n\tswitch n := v.(type) {\n\tcase float32:\n\t\tval = float64(n)\n\tcase float64:\n\t\tval = n\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"received unknown value type: want a float, got %T\", n))\n\t}\n\n\treturn encVarUintZ(bits.ReverseBytes64(math.Float64bits(val)))\n}\n\nfunc decFloat(t reflect.Type, data []byte) (typex.T, error) {\n\tuval, err := decVarUintZ(reflectx.Uint64, data)\n\tif err != nil {\n\t\treturn nil, errors.Errorf(\"invalid float encoding for: %v\", data)\n\t}\n\n\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:","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/coderx/float.go#L29-L65","documentation":"decFloat decodes a byte slice as a zig-zag varuint-encoded, byte-reversed 64-bit float. If the underlying decVarUintZ decode fails (malformed varint: truncated or overlong data), the coder wraps the failure as 'invalid float encoding'. It signals corrupted or mismatched encoded data, not a bad float value.","triggerScenarios":"Calling decFloat (via the 'float' custom coder's Decode) with bytes not produced by encFloat — e.g. decoded with the wrong coder, data truncated, or cross-language coder mismatch.","commonSituations":"Reading old data written with a different coder scheme, corrupt files/messages, or mixed SDK versions where float encoding differs.","solutions":["Verify the data was encoded with the same NewFloat coder (encFloat) that is being used to decode.","Check for truncation or corruption in the source (file, message queue) before decoding.","Log the offending data bytes to confirm they start with a valid uvarint prefix.","Re-write the dataset with the current coder if the encoding scheme changed between versions."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate a buffer before float decode\nfunc validFloatEncoding(data []byte) bool {\n    _, size := binary.Uvarint(data)\n    return size > 0 && size <= len(data)\n}","typeGuard":"func isFloatCoder(c *coder.CustomCoder) bool { return c.Name == \"float\" }","tryCatchPattern":"val, err := customCoder.Decode(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid float encoding\") {\n        log.Warnf(\"skipping corrupt float record: % x\", data)\n        return nil, nil // or route to a dead-letter output\n    }\n    return nil, err\n}","preventionTips":["Always pair encFloat/decFloat from the same NewFloat coder instance.","Include length prefixes when storing encoded floats in streams or files.","Never mix coder schemes across pipeline versions without a migration.","Checksum payloads written to durable storage to detect corruption early."],"tags":["go","apache-beam","decoding","serialization","corrupt-data"],"backgroundTag":"invalid-argument-format","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"}