-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal wire type...what doe it mean in general? #313
Comments
Basically, wire type 2 is a length delimited value (like a string, a couple of bytes, an inner message), while wire type 3 is the start of a legacy group, which is something entirely different. Wire types are used in the binary format to define which exact data type is following and an illegal wire type makes it impossible to decode the data correctly. This is usually caused by corruption of the binary data, like when converting to strings and back. |
The funny thing is that when I send protobuf message A, it works, and then when I send a slightly modified protobuf message (let's call it B) I get this error. I don't think google server would send me a corrupted response to one message and a correct one to a similar one. Do you think it would? Or are there chances there's a bug in the library? |
Whether the data becomes corrupted or not also depends on the data in this scenario, so it is possible that one payload works while others don't. It's like converting raw bytes to UTF8: The first 128 characters are just ASCII, while other characters combine multiple bytes. Converting that back to ASCII most of the time gives you strange results, depending on the characters used. If you are sure that the sender is giving you valid data, ensure to properly read the data as binary on your side and prevent any (implicit) conversion to a string (or explicitly use base64, hex, a real (internal and carefully converted) binary string). See the link I provided previously for more information. |
Ok thanks. I think everything should work fine (using npm request):
So if the Protobuf.js is fine, I'll try out some other request module... |
Maybe you could paste the raw response you receive so we can take a look at it. |
Ok, this is the binary response:
The error message, when running the And the protocol buffer in use is this https://github.com/kitt-browser/chrome-sync/blob/master/src/js/sync.proto.js The data above represents one ClientToServerResponse. |
It maybe character 10...I get an illegal character on that. I am serializing my object in another enviroment than node.js |
This was a consequence of #355. Fixed. |
Should Not sure why @Ishanisarkar's post is below the response now. |
I am writing a protocol which exchange messages between two clients directly using WebRTC. I have a message with two string fields. My proto file looks like : syntax proto3 try { Do tell me if there is a need for more information.Thank You in advance. |
I am not very clear as to how these functions work, so I tried testing it with just encode and decode functions too rather than encodeDelimited() and decodeDelimited().. It still gives the same error. |
@dcodeIO I am sorry its my mistake, I thought I should create a new issue rather than commenting here. |
I checked by making the decode(encodeDeliited) as decodeDelimited(encodeDelimited). It still gives the same error. Plus it is strange because the other message which contains only the id works just fine. |
This is the encoded buffer. Does this buffer make sense : [98, 191, 1, 16, 36, 99, 48, 57, 101, 50, 54, 98, 51, 45, 98, 99, 49, 100, 45, 52, 51, 55, 101, 45, 98, 100, 102, 52, 45, 49, 102, 101, 97, 49, 48, 55, 100, 53, 57, 52, 101, 10, 150, 1, 104, 116, 116, 112, 58, 47, 47, 99, 100, 110, 97, 109, 100, 45, 104, 108, 115, 45, 103, 108, 111, 98, 101, 99, 97, 115, 116, 46, 97, 107, 97, 109, 97, 105, 122, 101, 100, 46, 110, 101, 116, 47, 108, 105, 118, 101, 47, 114, 97, 109, 100, 105, 115, 107, 47, 98, …]. According to the explanation here #55, the wire type is 0? whereas it should be 2. Any possible reason why ? |
Usually happens when binary becomes accidentally converted to a string and back, see. |
I read the explanation you pointed too. |
Any updates on this error? I'm running into the same thing |
In a complex code I receive a response . When I tried to decode it, I got:
[Error: Illegal wire type for field Message.Field .sync_pb.CommitResponse.entryresponse: 3 (2 expected)]
Could you please exaplain what it means? Th error itself doesn't clarify much.
One of the response fields is CommitResponse.entryresponse. What wrong could have happened?
And I get this response only if I supply the request with a specific (valid) value.
The text was updated successfully, but these errors were encountered: