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

Conversation

frankxjkuang
Copy link
Contributor

script := return redis.call('get', KEYS[1])
keys := []string{"key"}
// When the args parameter is set to nil, it will cause a program panic
// As with the modified appendArg function, when entering the default branch and arg is nil, this code will cause pain
// painc: reflect: call of re reflect.Value.Type on zero Value
// if v.Type().Kind() == reflect.Ptr
vals, err := rdb.Eval(ctx, script, keys, nil).Result()
if err != nil {
panic(err)
}
fmt.Println("vals", vals)

@ndyakov
Copy link
Member

ndyakov commented Apr 22, 2025

Nice catch, thank you @frankxjkuang. Wound you mind adding a test case for it?

@frankxjkuang
Copy link
Contributor Author

好收获,谢谢@frankxjkuang。您介意为其添加一个测试用例吗?

Hello, should I add test cases for the appendArg function or add a parameter nil for Describe "Eval" and Describe "EvalRO"

@ndyakov
Copy link
Member

ndyakov commented Apr 22, 2025

好收获,谢谢@frankxjkuang。您介意为其添加一个测试用例吗?

Hello, should I add test cases for the appendArg function or add a parameter nil for Describe "Eval" and Describe "EvalRO"

Hello, ideally for both:

  • Tests for Eval and EvalRO will reproduce the previous bug.
  • Tests for appendArg will test the concrete fix.

Test the case of adding the args parameter nil for Eval and EvalRO
@frankxjkuang
Copy link
Contributor Author

好收获,谢谢@frankxjkuang。您介意为其添加一个测试用例吗?

Hello, should I add test cases for the appendArg function or add a parameter nil for Describe "Eval" and Describe "EvalRO"

Hello, ideally for both:

  • Tests for Eval and EvalRO will reproduce the previous bug.
  • Tests for appendArg will test the concrete fix.

Helllo, I have tested the case of adding the args parameter nil for Eval and EvalRO. In addition, since the appendArg function has not been exported, it is not possible to add test cases for them in command_test.go. I do not want to add a test file that would damage the integrity of the existing file structure. I believe this has already verified the case of the args parameter nil.

@ndyakov ndyakov merged commit 034a49f into redis:master Apr 23, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants