-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
*: replace erroneous uses of Newf
/Errorf
by Wrap
/Wrapf
#68707
Conversation
Arguably we'd need a linter for this. |
geo lgtm |
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.
Reviewed 18 of 22 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
pkg/ccl/cmdccl/enc_utils/main.go, line 205 at r2 (raw file):
cipher, err := aes.NewCipher(key.rawKey) if err != nil { return nil, errors.Wrapf("could not build AES cipher for file %s", absPath)
err
is not being wrapped.
pkg/cli/doctor.go, line 389 at r2 (raw file):
id = int(descpb.InvalidID) } else { return errors.Errorf(err, "failed to parse id %s", fields[3])
This is still the original Errorf
but with Wrapf
arguments.
pkg/kv/kvserver/store_split.go, line 338 at r2 (raw file):
leftRepl.writeStats.splitRequestCounts(rightRepl.writeStats) if err := s.addReplicaInternalLocked(rightRepl); err != nil { return errors.Wrapf(err, "unable to add replica %v: %s", rightRepl)
The %s
for the err
is still in the argument list.
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz and @mberhault)
pkg/ccl/cmdccl/enc_utils/main.go, line 205 at r2 (raw file):
Previously, mberhault (marc) wrote…
err
is not being wrapped.
Good catch. Fixed.
pkg/cli/doctor.go, line 389 at r2 (raw file):
Previously, mberhault (marc) wrote…
This is still the original
Errorf
but withWrapf
arguments.
Thanks fixed.
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @mberhault)
pkg/kv/kvserver/store_split.go, line 338 at r2 (raw file):
Previously, mberhault (marc) wrote…
The
%s
for theerr
is still in the argument list.
Fixed
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.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @mberhault)
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mberhault)
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.
Reviewed 3 of 22 files at r1, 1 of 3 files at r3, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @mberhault)
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.
Reviewable status: complete! 3 of 0 LGTMs obtained (waiting on @mberhault)
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.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: complete! 3 of 0 LGTMs obtained (waiting on @knz)
pkg/kv/kvserver/store_snapshot.go
Outdated
@@ -1155,7 +1155,7 @@ func sendSnapshot( | |||
// completed (such as defers that might be run after the previous message was | |||
// received). | |||
if unexpectedResp, err := stream.Recv(); err != io.EOF { | |||
return errors.Errorf("%s: expected EOF, got resp=%v err=%v", to, unexpectedResp, err) | |||
return errors.Wrapf(err, "%s: expected EOF, got resp=%v", to, unexpectedResp) |
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 haven't looked at the possible returns of stream.Recv()
; but this might be problematic if err == nil
since errors.Wrapf will return nil in that case.
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.
Woah, good catch
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.
Fixed
@jeffswenson still waiting for your look at the proxy changes |
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.
sqlproxyccl changes cc: @cockroachdb/sqlproxy-prs
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 3 stale) (waiting on @stevendanna)
bors r=mberhault,adityamaru,miretskiy,stevendanna,jaylim-crl,ajwerner,nvanbenschoten |
Build failed: |
flake on #68795 |
When constructing an error from another error, it is generally erroneous to use `Errorf("...%v", err)`: this deconstructs the original error back to a simple string and loses all its details. It also makes the original error opaque to redactability, to be considered an unsafe string, even if the original error already contained a mix of safe and unsafe strings. The proper approach is to use `errors.Wrap` / `errors.Wrapf`. This preserves any embedded details inside the error object and its redactability attributes. This change was obtained by running the following command and fixing up the results (i.e. test code was ignored): ``` git grep -E '(errors|fmt)\.(Errorf|Newf).*%v.*[eE]rr'|grep -v _test.go ``` Release note: None
bors r=mberhault,adityamaru,miretskiy,stevendanna,jaylim-crl,ajwerner,nvanbenschoten |
Build succeeded: |
This is an omnibus PR touching code by multiple teams. To be reviewed as follows:
See the description below for an explanation.
When constructing an error from another error, it is generally
erroneous to use
Errorf("...%v", err)
: this deconstructs theoriginal error back to a simple string and loses all its details.
It also makes the original error opaque to redactability, to be
considered an unsafe string, even if the original error already
contained a mix of safe and unsafe strings.
The proper approach is to use
errors.Wrap
/errors.Wrapf
.This preserves any embedded details inside the error object and its
redactability attributes.
This change was obtained by running the following command and fixing
up the results (i.e. test code was ignored):
Release note: None