-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix Panic in PRS due to a missing nil check #14656
Conversation
Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
@@ -7580,7 +7579,71 @@ func TestPlannedReparentShard(t *testing.T) { | |||
Nanos: 1, | |||
}, | |||
}, | |||
shouldErr: true, | |||
expectedErr: "duration: seconds:-1 nanos:1 is out of range for time.Duration", |
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 might be a bit unstable, how about expectedError error
and then asserting errors.Is(err, test.expectedErr)
?
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.
Why do you think this would be unstable? require.EqualError
takes in a string as a second argument. I thought it was meant to be used this way?
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.
right, but we ever change the exact wording of the error message, this test will break. versus if we just assert on the type of error being returned, it is more stable
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.
Oh I understand now! We want to assert on the type of error. I explored this possibility today, but unfortunately that won't work for this case. Because we are returning the error as fmt.Errorf("duration: %v is out of range for time.Duration", dpb)
it doesn't have a specific type that we can assert on. Plus I want to ensure we error out with the correct message and not with a different message that doesn't make sense.
I think for now this is fine and if we change the error message, then we should also change the expectations of the test.
Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
…14676) Signed-off-by: Manan Gupta <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
…14674) Signed-off-by: Manan Gupta <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Manan Gupta <[email protected]>
…14675) Signed-off-by: Manan Gupta <[email protected]> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com> Co-authored-by: Manan Gupta <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Description
This PR fixes the bug described in #14655. We were just missing a nil check and that has been added. This PR also adds a test to verify we don't see the panic anymore.
Related Issue(s)
Checklist
Deployment Notes