Skip to content

fix: Fix panic caused when arg is nil #3353

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

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func appendArg(dst []interface{}, arg interface{}) []interface{} {
return dst
case time.Time, time.Duration, encoding.BinaryMarshaler, net.IP:
return append(dst, arg)
case nil:
return dst
default:
// scan struct field
v := reflect.ValueOf(arg)
Expand Down
22 changes: 22 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7209,6 +7209,17 @@ var _ = Describe("Commands", func() {
Expect(err).NotTo(HaveOccurred())
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
})

It("returns empty values when args are nil", func() {
vals, err := client.Eval(
ctx,
"return {ARGV[1]}",
[]string{},
nil,
).Result()
Expect(err).NotTo(HaveOccurred())
Expect(vals).To(BeEmpty())
})
})

Describe("EvalRO", func() {
Expand All @@ -7232,6 +7243,17 @@ var _ = Describe("Commands", func() {
Expect(err).NotTo(HaveOccurred())
Expect(vals).To(Equal([]interface{}{int64(12), proto.RedisError("error"), "abc"}))
})

It("returns empty values when args are nil", func() {
vals, err := client.EvalRO(
ctx,
"return {ARGV[1]}",
[]string{},
nil,
).Result()
Expect(err).NotTo(HaveOccurred())
Expect(vals).To(BeEmpty())
})
})

Describe("Functions", func() {
Expand Down
Loading