Closed un000 closed 11 months ago
PR Fixes panics like this:
panic: reflect.Value.Convert: value of type string cannot be converted to type int goroutine 1 [running]: reflect.Value.Convert({0x1009b2c00?, 0x1400001e150?, 0x140000bd348?}, {0x100a28de8, 0x1009b2480}) /opt/homebrew/Cellar/go/1.20.1/libexec/src/reflect/value.go:3257 +0x104 github.com/aerospike/aerospike-client-go/v6.setValue({0x1009b2480?, 0x14000026388?, 0x140000bd7f8?}, {0x1009b2c00, 0x1400001e150}) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/read_command_reflect.go:153 +0x278 github.com/aerospike/aerospike-client-go/v6.setObjectField(0x1009d3da0?, {0x1009d3da0?, 0x14000026388?, 0x10000?}, {0x140000bd7f8, 0x3}, {0x1009b2c00, 0x1400001e150}) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/read_command_reflect.go:136 +0xac github.com/aerospike/aerospike-client-go/v6.parseObject(0x1400013e000, 0x1, 0x0?, 0x10000?, 0x0?) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/read_command_reflect.go:90 +0x480 github.com/aerospike/aerospike-client-go/v6.(*readCommand).parseResult(0x1400013e000, {0x100a27528, 0x1400013e000}, 0x10000?) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/read_command.go:171 +0x64c github.com/aerospike/aerospike-client-go/v6.(*baseCommand).executeAt(0x1400013e000, {0x100a27528, 0x1400013e000}, 0x140000322d0, 0x0?, {0x0?, 0x0?, 0x100bfd480?}, 0x0?, 0x0?) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/command.go:2617 +0xc5c github.com/aerospike/aerospike-client-go/v6.(*baseCommand).execute(0x0?, {0x100a27528, 0x1400013e000}, 0x0?) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/command.go:2440 +0x74 github.com/aerospike/aerospike-client-go/v6.(*readCommand).Execute(...) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/read_command.go:264 github.com/aerospike/aerospike-client-go/v6.(*Client).GetObject(0x1400006e3c0, 0x100a20f88?, 0x10090294e?, {0x1009aaa20?, 0x14000026388}) /Users/un0/go/pkg/mod/github.com/aerospike/aerospike-client-go/v6@v6.12.0/client_reflect.go:75 +0x318 main.main() /Users/un0/go/src/cmd/reproducer/main.go:32 +0x1f0 exit status 2
They happens because of mismatching types inside Aerospike and struct type definitions.
@khaf
@khaf could you review this?
@un000 Sure, sorry for the delay. Will release this week.
Reproducer
``` package main import ( "log" "github.com/aerospike/aerospike-client-go/v6" "github.com/davecgh/go-spew/spew" ) type object struct { Foo int `as:"foo"` // !!! type of Foo is int } func main() { client, err := aerospike.NewClient("127.0.0.1", 3002) if err != nil { log.Fatal(err) } defer client.Close() key, err := aerospike.NewKey("subscriptions", "test", "test") if err != nil { log.Fatal(err) } if err := client.PutBins(nil, key, aerospike.NewBin("foo", "bar")); err != nil { // !!! type of "foo" is string log.Fatal(err) } obj := &object{} if err := client.GetObject(nil, key, obj); err != nil { // panic log.Fatal(err) } spew.Dump(obj) } ```PR Fixes panics like this:
They happens because of mismatching types inside Aerospike and struct type definitions.
@khaf