{"record":{"id":"245f1f5ab7518cab","repo":"thanos-io/thanos","slug":"proto-wrong-wiretype-d-for-field-numlabelpairs","errorCode":null,"errorMessage":"proto: wrong wireType = %d for field NumLabelPairs","messagePattern":"proto: wrong wireType = (.+?) for field NumLabelPairs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/status/statuspb/rpc.pb.go","lineNumber":1728,"sourceCode":"\t\t\t}\n\t\t\tm.NumSeries = 0\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowRpc\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tm.NumSeries |= uint64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\tcase 2:\n\t\t\tif wireType != 0 {\n\t\t\t\treturn fmt.Errorf(\"proto: wrong wireType = %d for field NumLabelPairs\", wireType)\n\t\t\t}\n\t\t\tm.NumLabelPairs = 0\n\t\t\tfor shift := uint(0); ; shift += 7 {\n\t\t\t\tif shift >= 64 {\n\t\t\t\t\treturn ErrIntOverflowRpc\n\t\t\t\t}\n\t\t\t\tif iNdEx >= l {\n\t\t\t\t\treturn io.ErrUnexpectedEOF\n\t\t\t\t}\n\t\t\t\tb := dAtA[iNdEx]\n\t\t\t\tiNdEx++\n\t\t\t\tm.NumLabelPairs |= int64(b&0x7F) << shift\n\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\tcase 3:\n\t\t\tif wireType != 0 {","sourceCodeStart":1710,"sourceCodeEnd":1746,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/status/statuspb/rpc.pb.go#L1710-L1746","documentation":"Generated gogoproto Unmarshal code for the Statistic message (pkg/status/statuspb/rpc.pb.go:1728) rejects a wire value whose field 2 (NumLabelPairs) uses a wire type other than 0 (varint). This means the bytes being decoded do not match the compiled .proto schema — the wire data and the generated code disagree.","triggerScenarios":"Unmarshaling a TSDBStatistics/Statistic protobuf message where field number 2 arrives as a length-delimited (2), 64-bit (1), or 32-bit (5) type instead of a varint, typically because the sender uses a different schema version.","commonSituations":"Version mismatch between Thanos components (one built with an older/different rpc.proto); sending raw bytes written by a different generator (gogo vs google.golang.org/protobuf ordering); corrupt or hand-crafted gRPC payloads.","solutions":["Ensure both client and server are built from the same Thanos version so the generated rpc.pb.go and the sender's schema match","Regenerate the statuspb package with the same protoc/gogoproto versions used by the sender","Verify no proxy is rewriting/truncating the gRPC response","Check whether field numbering changed in rpc.proto (NumLabelPairs must be field 2, varint)","Enable gRPC wire-format logging to compare the raw bytes against the expected schema"],"exampleFix":"// before: mismatched schemas\nclient := statuspbv1 // built from old rpc.proto\n// after: pin the same generated package\nimport \"github.com/thanos-io/thanos/pkg/status/statuspb\"\nconn, _ := grpc.Dial(addr, grpc.WithCodec(statuspb.Codec))","handlingStrategy":"try-catch","validationCode":"// verify schema compatibility before streaming\nif !semverCompatible(peerVersion, minSupportedVersion) {\n    return fmt.Errorf(\"peer %s version %s incompatible for TSDB statistics\", peer, peerVersion)\n}","typeGuard":null,"tryCatchPattern":"if err := proto.Unmarshal(buf, &stat); err != nil {\n    if strings.Contains(err.Error(), \"wrong wireType\") {\n        return fmt.Errorf(\"schema mismatch with peer: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep all Thanos components on the same release","Regenerate protobuf code from a single canonical .proto","Never hand-edit generated *.pb.go files","Add contract tests that marshal on the sender and unmarshal on the receiver"],"tags":["protobuf","grpc","deserialization","wire-format","gogoproto"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}