Skip to content
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

sql/*: fix improperly wrapped errors #72350

Merged
merged 1 commit into from
Nov 3, 2021

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Nov 2, 2021

refs #42510

I'm working on a linter that detects errors that are not wrapped
correctly, and it discovered these.

Release note: None

@rafiss rafiss requested a review from a team November 2, 2021 20:50
@rafiss rafiss requested a review from a team as a code owner November 2, 2021 20:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss requested a review from a team November 2, 2021 20:50
Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: mod the comments

Reviewed 21 of 21 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/alter_column_type.go, line 410 at r1 (raw file):

var x = `se
`

what's this about?


pkg/sql/type_change_test.go, line 585 at r1 (raw file):

					}
					if !testutils.IsError(err, "invalid input value for enum") {
						return errors.AssertionFailedf("expected invalid input for enum error, found %v", err)

I think you've got another case to add to your linter. Shouldn't this use errors.NewAssertionErrorWithWrappedErrf

Copy link
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)


pkg/sql/alter_column_type.go, line 410 at r1 (raw file):

Previously, ajwerner wrote…
var x = `se
`

what's this about?

no idea; nice catch


pkg/sql/type_change_test.go, line 585 at r1 (raw file):

Previously, ajwerner wrote…

I think you've got another case to add to your linter. Shouldn't this use errors.NewAssertionErrorWithWrappedErrf

hm so this one i wasn't quite sure what to do. not wrapping the error here made sense to me since the problem in this case is that an error was expected, but it was the wrong type. but NewAssertionErrorWithWrappedErrf seems like the best of both worlds; didn't know about that.

Copy link
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)


pkg/sql/type_change_test.go, line 585 at r1 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

hm so this one i wasn't quite sure what to do. not wrapping the error here made sense to me since the problem in this case is that an error was expected, but it was the wrong type. but NewAssertionErrorWithWrappedErrf seems like the best of both worlds; didn't know about that.

and i'll make sure my linter looks for this function too. (will send that PR up once these fix PRs are in)

@rafiss rafiss force-pushed the fix-sql-errwrap branch 3 times, most recently from 1ef44e0 to 26e23af Compare November 3, 2021 00:20
I'm working on a linter that detects errors that are not wrapped
correctly, and it discovered these.

Release note: None
@rafiss
Copy link
Collaborator Author

rafiss commented Nov 3, 2021

bors r=ajwerner

@craig
Copy link
Contributor

craig bot commented Nov 3, 2021

Build failed:

@rafiss
Copy link
Collaborator Author

rafiss commented Nov 3, 2021

bors r=ajwerner

@craig
Copy link
Contributor

craig bot commented Nov 3, 2021

Build failed:

@rafiss
Copy link
Collaborator Author

rafiss commented Nov 3, 2021

bors r=ajwerner

@craig
Copy link
Contributor

craig bot commented Nov 3, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Nov 3, 2021

Build succeeded:

@craig craig bot merged commit 72b843f into cockroachdb:master Nov 3, 2021
@rafiss rafiss deleted the fix-sql-errwrap branch November 3, 2021 21:51
craig bot pushed a commit that referenced this pull request Dec 15, 2021
71877: lint: add new errwrap linter r=ajwerner,knz a=rafiss

fixes #42510

This linter checks if we don't correctly wrap errors.

The `/* nolint:errwrap */` comment can be used to disable the linter inline.

See individual commits for mistakes this linter caught.
It had already caught a few in #72353, #72352, #72351, #72350, and #72349.

Release note: None

Co-authored-by: Rafi Shamim <[email protected]>
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.

3 participants