Closed KaymeKaydex closed 7 months ago
but data non-empty
Please give an example of the code in which you decode the response with GetTyped()
and the response decoded as {}interface with Get()
.
Ideally I would like to see a minimal reproducer.
Now it’s not entirely clear to me what’s not working for you.
I got it. You need to write a custom decoder for this cases, as example:
type testReproducer368 struct {
Value int
Foo string
}
func (t *testReproducer368) DecodeMsgpack(d *msgpack.Decoder) error {
var (
err error
l int
)
if l, err = d.DecodeMapLen(); err != nil {
return err
}
for i := 0; i < l; i++ {
key, err := d.DecodeInterface()
if err != nil {
return err
}
value, err := d.DecodeInterface()
if err != nil {
return err
}
switch key {
case int8(34):
t.Value = int(value.(int8))
case "foo":
t.Foo = value.(string)
}
}
return nil
}
func TestReproducer368(t *testing.T) {
conn := test_helpers.ConnectWithValidation(t, dialer, opts)
defer conn.Close()
test := []testReproducer368{}
err := conn.Do(NewEvalRequest("return {[34] = 2, foo = 'bar'}")).GetTyped(&test)
require.NoError(t, err)
require.Equal(t, []testReproducer368{testReproducer368{2, "bar"}}, test)
}
You could see examples of the custom decoders in the connector code or in the msgpack
library. See:
https://github.com/vmihailenco/msgpack/issues/314
The reason in the msgpack
library implementation, we can't fix it on our side.
msgpack: invalid code=1 decoding string/bytes length
https://github.com/vmihailenco/msgpack/blob/19c91dfdfa062658c39d9321be26163fc5833bd1/decode_string.go#L31