I'm decoding some buffers with Google protobuffer. I'm using the excellent @decodeIO ProtoBuf.js module.
When I try to decode this Buffer:
<Buffer 0a 0b 47 57 5f 2d 31 38 5f 39 39 32 39>
From this message:
message PaymentResponseElement {
optional int64 pnPaymentId = 1;
optional string messageCode = 2; //won't use pb enum here
optional int64 balanceAfterTransaction = 3;
optional int32 version = 4;
}
I get this error:
Error: Illegal wire type for field Message.Field .core.comm.PaymentResponseElement.messageCode: 2 (0 expected)
at ProtoBuf.Reflect.Field.decode (/home/joojo/node_modules/protobufjs/ProtoBuf.js:2095:27)
at ProtoBuf.Reflect.Message.decode (/home/joojo/node_modules/protobufjs/ProtoBuf.js:1748:51)
at ProtoBuf.Reflect.Field.decode (/home/joojo/node_modules/protobufjs/ProtoBuf.js:2196:46)
at ProtoBuf.Reflect.Message.decode (/home/joojo/node_modules/protobufjs/ProtoBuf.js:1746:51)
at Function.Message.decode (/home/joojo/node_modules/protobufjs/ProtoBuf.js:1630:41)
at decode (/home/joojo/public_html/api/control/protoBuffer.js:94:52)
at Object.module.exports.decode (/home/joojo/public_html/cageapi/control/protoBuffer.js:110:10)
at decode (/home/joojo/public_html/api/control/messageStructurer.js:82:33)
at Object.module.exports.decode (/home/joojo/public_html/api/control/messageStructurer.js:94:10
at CleartextStream.month (/home/joojo/public_html/api/connectionHandler.js:83:32)
Don't know whats going on, and it's happened a few times. How to fix it?
I have to agree with the implementation. That data is only 1 field - field number 1, length-prefixed (could be a string, binary, or a sub-message edit or packed-array); if we speculatively interpret it as a string (which is always UTF-8 in protouf), it comes out as "GW_-18_9929", which looks sane.
However, your message declared field 1 as int64. The string/length-prefix wire-type (wire-type 2) is not valid for int64 - in fact, the only valid wire-type for that is 64-bit (wire-type 1).
So: your data is valid, but it doesn't match the schema you are claiming.
To unscramble:
"GW_-18_9929"If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With