{"record":{"id":"9dd1aea663c4136b","repo":"apache/beam","slug":"invalid-varuintz-encoding-for-v","errorCode":null,"errorMessage":"invalid varuintz encoding for: %v","messagePattern":"invalid varuintz encoding for: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/coderx/varint.go","lineNumber":116,"sourceCode":"\t\tval = uint64(n)\n\tcase uint16:\n\t\tval = uint64(n)\n\tcase uint32:\n\t\tval = uint64(n)\n\tcase uint64:\n\t\tval = n\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"received unknown value type: want an unsigned integer:, got %T\", n))\n\t}\n\tret := make([]byte, binary.MaxVarintLen64)\n\tsize := binary.PutUvarint(ret, val)\n\treturn ret[:size]\n}\n\nfunc decVarUintZ(t reflect.Type, data []byte) (typex.T, error) {\n\tn, size := binary.Uvarint(data)\n\tif size <= 0 {\n\t\treturn nil, errors.Errorf(\"invalid varuintz encoding for: %v\", data)\n\t}\n\tswitch t.Kind() {\n\tcase reflect.Uint:\n\t\treturn uint(n), nil\n\tcase reflect.Uint8:\n\t\treturn uint8(n), nil\n\tcase reflect.Uint16:\n\t\treturn uint16(n), nil\n\tcase reflect.Uint32:\n\t\treturn uint32(n), nil\n\tcase reflect.Uint64:\n\t\treturn n, nil\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unreachable statement: expected an unsigned integer, got %v\", t))\n\t}\n}\n","sourceCodeStart":98,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/coderx/varint.go#L98-L133","documentation":"decVarUintZ decodes bytes with binary.Uvarint. If Uvarint returns size <= 0 the data is malformed or truncated and this error is returned. Note this function is also the inner decode step for the float coder, so a float decode failure can surface from here first.","triggerScenarios":"Decoding (via 'varuintz' custom coder or decFloat) byte slices not produced by encVarUintZ — truncated data, wrong coder, or corrupted payload.","commonSituations":"Mixing signed varintz and unsigned varuintz data; reading partial buffers from network streams; old data written under a different encoding.","solutions":["Ensure the data was encoded with the matching encVarUintZ / encFloat scheme.","Fix record framing so the full varint bytes are present before decoding.","Verify you aren't feeding varintz (signed) data into the unsigned decoder.","Log the raw bytes to confirm the leading varint header is valid."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validVarUintZ(data []byte) bool {\n    _, size := binary.Uvarint(data)\n    return size > 0\n}","typeGuard":"func isVarUintZCoder(c *coder.CustomCoder) bool { return c.Name == \"varuintz\" }","tryCatchPattern":"val, err := coder.Decode(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid varuintz encoding\") {\n        log.Warnf(\"bad varuintz record: % x\", data)\n        return nil, nil // dead-letter instead\n    }\n    return nil, err\n}","preventionTips":["Match encoder and decoder exactly: encVarUintZ data must go to decVarUintZ (or decFloat for floats).","Length-prefix records in streams to avoid partial varint reads.","Keep SDK versions aligned on both sides of cross-language pipelines.","Validate the first byte(s) form a complete uvarint before decoding."],"tags":["go","apache-beam","decoding","varint","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"}