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
Specify msgpack decode option to return strings for appropriate types #116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure the tests are passing. I see a nasty panic on the ci logs.
panic: interface conversion: interface {} is string, not []uint8 [recovered]
panic: interface conversion: interface {} is string, not []uint8
Also
// RawToString controls how raw bytes are decoded into a nil interface{}.
RawToString bool
Now we really dont want this behavior. I considered this before and decided it should not be used because strings in go are utf-8
meaning this will mangle any raw bytes encoded in msgpack.
OK, but I think you're misreading the intent of the option. In older msgpack versions there was no distinction between binary and string values, and they were labelled as a single "raw" type. Then the spec was changed to introduce separate string and binary types, and there was a migration path where the legacy "raw" types could be interpreted as either a string or binary value. See https://github.com/msgpack/msgpack/blob/master/spec.md#upgrading-messagepack-specification This option in the library affects the decoding of various opcode ranges, particularly the opcodes that were historically raw types. The opcode for the "client1" member in the message data was |
Agreed, I need to look at this. |
See eb6dba9: this was an error in the test, incorrectly expecting some members of decoded messages to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We need to specify
RawToString: true
: https://github.com/ugorji/go/blob/master/codec/msgpack.go#L521