Skip to content

fix: use %v instead of %w in logrus error messages - #1377

Open
ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/logrus-format-verb
Open

ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/logrus-format-verb

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Fixes #1376.

%w is only valid for fmt.Errorf. Two logrus Errorf calls used it (cmd/notation/internal/flag/options.go for the credential helper trace and internal/trace/transport.go for the HTTP transport trace), so the --debug output contained %!w(*errors.errorString=...) instead of the error message. This changes both to %v.

Tests: TestWithExecutableTrace_ExecuteDoneLogsError and TestTransport_RoundTrip_LogsResponseError capture the logger output and check that it contains the error message and no formatting error. Both fail without the change.

%w is only valid for fmt.Errorf. The two logrus Errorf calls that used it
(the credential helper trace and the HTTP transport trace) went through
Sprintf, so the debug output contained "%!w(*errors.errorString=...)"
instead of the error message.

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.20%. Comparing base (9ba75db) to head (d53674f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1377      +/-   ##
==========================================
+ Coverage   80.10%   80.20%   +0.09%     
==========================================
  Files          68       68              
  Lines        3076     3076              
==========================================
+ Hits         2464     2467       +3     
+ Misses        403      399       -4     
- Partials      209      210       +1     

☔ 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.

debug logs contain %!w(...) instead of the error for credential helper and HTTP transport failures

1 participant