Skip to content

fix: use %w instead of %v for error wrapping in login and logout#1349

Open
ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/error-wrapping-login-logout
Open

fix: use %w instead of %v for error wrapping in login and logout#1349
ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/error-wrapping-login-logout

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

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 with errors.Is/errors.As. The house style across the rest of the codebase already uses %w for 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)

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>
Copilot AI review requested due to automatic review settings June 10, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) with fmt.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

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.09%. Comparing base (51ff5ec) to head (00698d6).

Files with missing lines Patch % Lines
cmd/notation/login.go 0.00% 3 Missing ⚠️
cmd/notation/logout.go 0.00% 2 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants