-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
[decode] regression from v4: invalid code=d3 decoding string/bytes length
on complex nested structure
#327
Labels
Comments
lizthegrey
changed the title
regression from v4:
[decode] regression from v4: Dec 5, 2021
invalid code=d3 decoding string/bytes length
on complex nested structureinvalid code=d3 decoding string/bytes length
on complex nested structure
Hi, The smaller reproducer looks like this: package main
import (
"bytes"
"fmt"
v4 "github.com/vmihailenco/msgpack/v4"
v5 "github.com/vmihailenco/msgpack/v5"
)
func main() {
var ret interface{}
b, _ := v4.Marshal(map[string]interface{}{
"2": map[int64]int64{
3: 4,
},
})
fmt.Println(b)
decoder := v5.NewDecoder(bytes.NewReader(b))
// decoder.SetMapDecoder(func(dec *v5.Decoder) (interface{}, error) {
// return dec.DecodeTypedMap()
// })
decoder.UseLooseInterfaceDecoding(true)
decoder.SetCustomStructTag("json")
err := decoder.Decode(&ret)
fmt.Println(err)
fmt.Println(ret)
} To fix it, uncomment the code that sets map decoder. This behavior is explained and documented here. I am not sure there is anything else we can do. |
oleg-jukovec
added a commit
to tarantool/go-tarantool
that referenced
this issue
May 19, 2022
An user can continue to use msgpack.v2 with tag: go_tarantool_msgpack_v2 There are two problems that cannot be unified: - Different signature and logic of RegisterExt in msgpack.v2[1] and msgpack.v5[2]. - Different logic of map decoding, see[3][4]. These issues have been fixed in msgpack.v5 implementation, see msgpack.go and uuid/msgpack.go. Files naming changed: msgpack.go - msgpack.v5 usage for the code msgpack_helper_test.go - msgpack.v5 usage for tests msgpack_v2.go - msgpack.v2 usage for the code msgpack_v2_helper_test.go - msgpack.v2 usage for tests 1. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#RegisterExt 2. https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#RegisterExt 3. vmihailenco/msgpack#327 4. https://msgpack.uptrace.dev/guide/#decoding-maps-into-an-interface/
oleg-jukovec
added a commit
to tarantool/go-tarantool
that referenced
this issue
May 19, 2022
An user can continue to use msgpack.v2 with tag: go_tarantool_msgpack_v2 There are two problems that cannot be unified: - Different signature and logic of RegisterExt in msgpack.v2[1] and msgpack.v5[2]. - Different logic of map decoding, see[3][4]. These issues have been fixed in msgpack.v5 implementation, see msgpack.go and uuid/msgpack.go. Files naming changed: msgpack.go - msgpack.v5 usage for the code msgpack_helper_test.go - msgpack.v5 usage for tests msgpack_v2.go - msgpack.v2 usage for the code msgpack_v2_helper_test.go - msgpack.v2 usage for tests 1. https://pkg.go.dev/github.com/vmihailenco/[email protected]+incompatible#RegisterExt 2. https://pkg.go.dev/github.com/vmihailenco/msgpack/v5#RegisterExt 3. vmihailenco/msgpack#327 4. https://msgpack.uptrace.dev/guide/#decoding-maps-into-an-interface/
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior (v4)
https://go.dev/play/p/BXgPx5l-SDf
Structure roundtrips successfully.
Current Behavior (v5)
Decode error happens when roundtripping
https://go.dev/play/p/5hcEjhSWohg
Steps to Reproduce
See above
v4 encode -> v5 decode has the error. https://go.dev/play/p/gYEuy6p42C6
v5 encode -> v4 decode does not have the error. https://go.dev/play/p/fQBCJZiW03f
The text was updated successfully, but these errors were encountered: