Skip to content

fix: use explicit format verb in logger middleware Printf calls#159

Closed
jaypeedaylee wants to merge 1 commit intomainfrom
fix/logger-middleware-printf-dynamic-format
Closed

fix: use explicit format verb in logger middleware Printf calls#159
jaypeedaylee wants to merge 1 commit intomainfrom
fix/logger-middleware-printf-dynamic-format

Conversation

@jaypeedaylee
Copy link

@jaypeedaylee jaypeedaylee commented Mar 6, 2026

Summary

  • Warnf(message), Errorf(message), and Infof(message) in pkg/middleware/logger.go pass a dynamic string directly as the format argument
  • This triggers staticcheck SA1006 (Printf with dynamic first argument and no further arguments)
  • URL paths containing % characters (e.g. %2F, %20) would be misinterpreted as format directives, producing garbled log output

Fix: Replace logger.Warnf(message)logger.Warnf("%s", message) (and same for Errorf/Infof)

Test plan

  • Existing middleware logger tests pass
  • golangci-lint run ./pkg/middleware/... reports no SA1006 violations

🤖 Generated with Claude Code


Note

Low Risk
Low risk: only changes log formatting calls to use an explicit %s verb, preventing % in URLs from being treated as format directives.

Overview
Updates the HTTP logger middleware to call Warnf/Errorf/Infof with an explicit "%s" format string instead of passing the preformatted message as the format argument.

This prevents % sequences in request URLs from being interpreted as format directives and resolves staticcheck SA1006 for these logging lines.

Written by Cursor Bugbot for commit 6488eb8. This will update automatically on new commits. Configure here.

Passing a dynamic string directly as a format argument to Warnf/Errorf/Infof
triggers staticcheck SA1006 and can misinterpret % characters in URL paths
(e.g. %2F, %20) as format directives, producing garbled output.

Use "%s" as an explicit format string instead.
@jaypeedaylee jaypeedaylee requested a review from a team as a code owner March 6, 2026 20:12
@jaypeedaylee jaypeedaylee deleted the fix/logger-middleware-printf-dynamic-format branch March 9, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant