protobuf.js icon indicating copy to clipboard operation
protobuf.js copied to clipboard

Error: invalid wire type 4

Open Alynva opened this issue 6 years ago • 3 comments

I'm getting the error invalid wire type 4 on Node v10.16.1 but it works on browser with the exactly same message and .proto file.

The problem is that that offset is part of a field, it's not a tag. Here is my hex data, happen on offset 21: 0a 1c 10 e1 bf b1 cc ce 99 c9 e3 15 1a 10 53 4d 57 54 65 7a 54 6c 53 4c 79 4b 4b 41 75 69 22 0f 18 90 d5 a5 ec 05 21 00 00 00 00 00 88 93 40

I tested it on Online Protobuf Decoder (without schema) and on Online Protobuf encoder/decoder (with schema) and both works perfectly. I tried the How to reverse engineer a buffer by hand but I was not able to go so far.

When I console the buffer it shows as <Buffer 0a 1c 10 e1 bf b1 cc ce 99 c9 e3 15 1a 10 53 4d 57 54 65 7a 54 6c 53 4c 79 4b 4b 41 75 69 22 0f 18 90 d5 a5 ec 05 21 00 00 00 00 00 88 93 40> (with de "Buffer" at start), could it causing this error? I used the ByteBuffer.fromDebug to get the buffer from hex data.

Alynva avatar Sep 24 '19 13:09 Alynva

any luck with this?

yoavmil avatar Jul 09 '20 14:07 yoavmil

Offset 21 is indeed in the middle of the string "SMWTezTlSLyKKAui":

$ echo 0a1c10e1bfb1ccce99c9e3151a10534d5754657a546c534c794b4b417569220f1890d5a5ec05210000000000889340 | xxd -r -p | protoc --decode_raw
1 {
  2: 1569263457672126433
  3: "SMWTezTlSLyKKAui"
}
4 {
  3: 1569286800
  4: 0x4093880000000000
}

Hexdump:

echo 0a1c10e1bfb1ccce99c9e3151a10534d5754657a546c534c794b4b417569220f1890d5a5ec05210000000000889340 | xxd -r -p | hexdump -C
00000000  0a 1c 10 e1 bf b1 cc ce  99 c9 e3 15 1a 10 53 4d  |..............SM|
00000010  57 54 65 7a 54 6c 53 4c  79 4b 4b 41 75 69 22 0f  |WTezTlSLyKKAui".|
00000020  18 90 d5 a5 ec 05 21 00  00 00 00 00 88 93 40     |......!.......@|
0000002f

Do you have the proto schema or protobufjs code to reproduce the error?

webmaster128 avatar Aug 07 '20 20:08 webmaster128

Any joy with this? Having a similar problem where it works online but not node-red...

FinlayKM avatar Aug 17 '23 16:08 FinlayKM