fix: use %w instead of %v for error wrapping in login and logout#1349
fix: use %w instead of %v for error wrapping in login and logout#1349ogulcanaydogan wants to merge 1 commit into
Conversation
Switch return fmt.Errorf calls in cmd/notation/login.go and cmd/notation/logout.go from %v to %w so callers can inspect the underlying error via errors.Is/errors.As. The house style across the rest of the codebase already uses %w for these patterns. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates CLI authentication commands to wrap underlying errors (instead of formatting them) so callers can unwrap and inspect root causes.
Changes:
- Replace
fmt.Errorf(...: %v, err)withfmt.Errorf(...: %w, err)in login/logout flows. - Preserve existing error messages while improving error chaining.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/notation/logout.go | Wraps credentials store and logout errors with %w for proper error chaining. |
| cmd/notation/login.go | Wraps credentials store, registry client, and login errors with %w for proper error chaining. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1349 +/- ##
=======================================
Coverage 79.09% 79.09%
=======================================
Files 68 68
Lines 3076 3076
=======================================
Hits 2433 2433
Misses 436 436
Partials 207 207 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Switch
return fmt.Errorf(...)calls incmd/notation/login.goandcmd/notation/logout.gofrom%vto%wso callers can inspect the underlying error witherrors.Is/errors.As. The house style across the rest of the codebase already uses%wfor these patterns (22 non-test files).Files changed:
cmd/notation/login.go(3 sites: credentials store, registry client, login failure)cmd/notation/logout.go(2 sites: credentials store, logout failure)