{"record":{"id":"8c1a4fdbdbcd4b71","repo":"thanos-io/thanos","slug":"proto-illegal-wiretype-d","errorCode":null,"errorMessage":"proto: illegal wireType %d","messagePattern":"proto: illegal wireType (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/status/statuspb/rpc.pb.go","lineNumber":1991,"sourceCode":"\t\t\t\tif b < 0x80 {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif length < 0 {\n\t\t\t\treturn 0, ErrInvalidLengthRpc\n\t\t\t}\n\t\t\tiNdEx += length\n\t\tcase 3:\n\t\t\tdepth++\n\t\tcase 4:\n\t\t\tif depth == 0 {\n\t\t\t\treturn 0, ErrUnexpectedEndOfGroupRpc\n\t\t\t}\n\t\t\tdepth--\n\t\tcase 5:\n\t\t\tiNdEx += 4\n\t\tdefault:\n\t\t\treturn 0, fmt.Errorf(\"proto: illegal wireType %d\", wireType)\n\t\t}\n\t\tif iNdEx < 0 {\n\t\t\treturn 0, ErrInvalidLengthRpc\n\t\t}\n\t\tif depth == 0 {\n\t\t\treturn iNdEx, nil\n\t\t}\n\t}\n\treturn 0, io.ErrUnexpectedEOF\n}\n\nvar (\n\tErrInvalidLengthRpc        = fmt.Errorf(\"proto: negative length found during unmarshaling\")\n\tErrIntOverflowRpc          = fmt.Errorf(\"proto: integer overflow\")\n\tErrUnexpectedEndOfGroupRpc = fmt.Errorf(\"proto: unexpected end of group\")\n)\n","sourceCodeStart":1973,"sourceCodeEnd":2008,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/status/statuspb/rpc.pb.go#L1973-L2008","documentation":"This error comes from gogo/golang generated protobuf unmarshal code in rpc.pb.go. When decoding a length-delimited or varint-encoded field, the wire type read from the tag byte must be one of 0-5; any other value means the byte stream is not a valid protobuf message. The generated skip function returns this error instead of silently misparsing corrupt data.","triggerScenarios":"Unmarshaling a protobuf message (here from pkg/status/statuspb or pkg/exemplars/exemplarspb) whose bytes were truncated, corrupted, or are not protobuf at all, so the parsed wireType in the skip loop falls outside the known range 0-5.","commonSituations":"Sending non-protobuf payloads to an endpoint expecting protobuf, mixing incompatible proto schema versions between client and server, or feeding compressed/garbage bytes into proto.Unmarshal.","solutions":["Verify the bytes being unmarshaled are actual protobuf wire format (not JSON, gzip, or truncated data).","Regenerate or re-align the .pb.go files so both producer and consumer use the same proto schema version.","Add checksum/length validation on the transport layer before calling Unmarshal.","Log the first bytes of the failing payload to confirm it starts with a valid protobuf field tag."],"exampleFix":"// before\nif err := proto.Unmarshal(data, msg); err != nil { return err }\n// after\nif len(data) == 0 { return errors.New(\"empty payload\") }\nif err := proto.Unmarshal(data, msg); err != nil {\n    return errors.Wrapf(err, \"invalid protobuf payload (first bytes: %x)\", data[:min(8, len(data))])\n}","handlingStrategy":"validation","validationCode":"func validProtobufPayload(data []byte) bool {\n    if len(data) == 0 { return false }\n    tag, n := binary.Uvarint(data)\n    return n > 0 && tag>>3 > 0 && tag&0x7 <= 5\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate payload framing before proto.Unmarshal","Keep proto schema versions in sync across services","Never feed compressed or JSON bytes to proto.Unmarshal"],"tags":["protobuf","unmarshal","data-corruption"],"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"}