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
blob: include key in error messages #2565
Conversation
@@ -768,8 +772,6 @@ func (b *Bucket) NewWriter(ctx context.Context, key string, opts *WriterOptions) | |||
end: end, | |||
cancel: cancel, | |||
key: key, | |||
opts: dopts, |
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.
These two fields (along with ctx
) are only supposed to be set when we need to call NewTypedWriter
later; they are explicitly set in the else
a few lines down. I'm not sure why we were setting them here, they are not needed and it made the code unclear because the comment in the struct says they are only set when w
is nil
.
I removed them and clarified the comments.
Codecov Report
@@ Coverage Diff @@
## master #2565 +/- ##
==========================================
+ Coverage 66.65% 66.71% +0.06%
==========================================
Files 133 133
Lines 15489 15488 -1
==========================================
+ Hits 10324 10333 +9
+ Misses 4398 4387 -11
- Partials 767 768 +1
Continue to review full report at Codecov.
|
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 with one nit.
Fixes #2564.
See the bug for context. TL;DR, services don't usually include the key in error messages (e.g., "The specified key does not exist" without saying what the key was). That lack of info can make debugging difficult. This PR adds the key (where possible) to error messages from
blob
, via the portable type.For example, the GCS error for a missing blob was:
blob (code=NotFound): storage: object doesn't exist
and after this change it is:
blob (key not-found) (code=NotFound): storage: object doesn't exist
I also added a conformance test for
Bucket.Attributes
for a nonexistent key.