-
Notifications
You must be signed in to change notification settings - Fork 468
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
Add type check before metadata decode #2015
Conversation
message := "ERR Invalid argument: WRONGTYPE Operation against a key holding the wrong kind of value" | ||
require.NoError(t, rdb.Set(ctx, "a", "hello", 0).Err()) | ||
require.EqualError(t, rdb.Do(ctx, "XADD", "a", "*", "a", "test").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "LPUSH", "a", 1).Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "HSET", "a", "1", "2").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "SADD", "a", "1", "2").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "ZADD", "a", "1", "2").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "JSON.SET", "a", "$", "{}").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "BF.ADD", "a", "test").Err(), message) | ||
require.EqualError(t, rdb.Do(ctx, "SADD", "a", 100).Err(), message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test case can pass without these changes, regardless of error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is designed to ensure that the error message is consistent with Redis.
Based on my experience, it's difficult for me to associate the problem with inconsistent key types when I see other error messages.
So I wrote this test case to prevent future users from being confused by meaningless error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments : )
Instead, if you want to fix #2012, I think a better way is to change |
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
@PragmaTwice For the tests, I think it is necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 7 New issues |
In this PR I add type check before metadata decode.
I also add some test cases about operating with the wrong type
It fixes #2012