fix: use explicit format verb in logger middleware Printf calls#159
Closed
jaypeedaylee wants to merge 1 commit intomainfrom
Closed
fix: use explicit format verb in logger middleware Printf calls#159jaypeedaylee wants to merge 1 commit intomainfrom
jaypeedaylee wants to merge 1 commit intomainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Warnf(message),Errorf(message), andInfof(message)inpkg/middleware/logger.gopass a dynamic string directly as the format argumentPrintf with dynamic first argument and no further arguments)%characters (e.g.%2F,%20) would be misinterpreted as format directives, producing garbled log outputFix: Replace
logger.Warnf(message)→logger.Warnf("%s", message)(and same forErrorf/Infof)Test plan
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
%sverb, preventing%in URLs from being treated as format directives.Overview
Updates the HTTP logger middleware to call
Warnf/Errorf/Infofwith 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 staticcheckSA1006for these logging lines.Written by Cursor Bugbot for commit 6488eb8. This will update automatically on new commits. Configure here.