-
Notifications
You must be signed in to change notification settings - Fork 14
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
Emptish objects fail to roundtrip cbor marshal & unmarshal #10
Comments
Two sources of problem: - the wrong byte was being encoded for nil...! Youch. - a stack pop was performed as if nils weren't terminals, which could cause panics. Both should now be fixed. The fixtures we already had for empty and zero values should've caught this... but unfortunately we hadn't mapped them onto corresponding CBOR byte fixtures. That oversight is now fixed (and we added more fixtures, to boot), but we should also really fix the root cause of that oversight and write a test that we've got enough tests mapped consistently in all directions >.< Thanks to dignifiedquire for his stellar bug reporting. This should fix issue #10. (The "invalid major byte" from unmarshal was actually a valid complaint; it's also fixed by fixing the wrong byte emitted from the marshal side.) Signed-off-by: Eric Myhre <hash@exultant.us>
Ok, I think all these are fixed on master as well. Thank you for this heroic and excellent bug reporting! (I'm particularly embarrassed in this case -- there were fixtures on the token side meant to cover precisely these cases... but no mappings defined on the matching the cbor side. It's to the point I should be writing tests to make sure the texts are fully filling out the |
Thanks for the quick turn around, I have some more issues I am afraid
|
It would probably be useful to add a bunch of test vectors, making sure things work as expected. Some I have used in the past and might be useful
|
Sorry E_TIME_BUDGET happened a bit... I'll try to allocate some time this evening. At first glance, these are probably issues with nil-vs-typed-nil being handled inconsistently in the obj mapper package rather than a cbor problem. So I'll be focusing on adding unit tests and fixtures there. Those borc tools look useful...! Maybe with a little work I can rig them around the |
Fixed the issue with nulls, thanks. I can't reproduce your issue with |
Thanks, I'll check it out. There is always the chance my code is the issue :) |
Turns out the |
Even more test coverage is a very acceptable "problem" to have as a sideeffect :) |
Trying some simple edge cases and got these issues
Emptyish objects that fail to round trip
(
fmt.Printf("%s - %s\n", obj, reflect.TypeOf(obj))
)[] - interface[]{}
:panic: cborEncoder stack overpopped
(marshal)[<nil>] - interface[]{}
:Invalid majorByte: 0xff
(unmarshal)<nil> - %!s(<nil))
:panic: cborEncoder stack overpopped
(marshal)(Setup is as described in #9)
The text was updated successfully, but these errors were encountered: