Repository navigation
fix: stop error text being read as a format string - #1280
Conversation
The logger's Error, Warn, Info and Debug treat their first argument as a format string. Passing message text there garbled any % in it, so a URL-encoded slash (%2F) printed as %!F(MISSING). Each logger method now calls fmt.Sprintf(format, v...) directly. That lets go vet, and golangci-lint in CI, see them as printf-style and reject a format that isn't a constant. Fixed the 18 call sites it found, plus three Azure debug lines that passed values with no %s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @AlexKantor87's task in 27s —— View job Follow-up review completeReviewed
|
Snyk Code treats os.Args as untrusted input reaching exec.Command. os.Executable gives the same test binary without that path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
On the suggestion to add a logger unit test: declined. A test like no search: this reply changes no code 🤖 Addressed by Claude Code |
Follow-up review of latest commits (
|
Fixes #1279
What was wrong
The logger's
Error,Warn,InfoandDebugtreat their first argument as a format string.main.gopassed the error text there, so any%in an error was garbled. A URL-encoded slash (%2F) printed as%!F(MISSING).Why vet missed it
go vetrejects a format string that isn't a constant. It only does this for functions it knows are printf-style. Each logger method changedformatbefore using it, so vet couldn't tell.Fix
fmt.Sprintf(format, v...)directly. Output is the same for every well-formed call. Vet, and golangci-lint in CI, now check every logger call.logger.Error("%s", err.Error()).%s, so they printed%!(EXTRA ...). Fixed too.fmt.Errorf,fmt.Printfandlog.Printfalready had vet coverage, with no findings.Test
TestMainErrorKeepsPercentEncodingrunsmain()in a child process, becauselogger.Errorexits the process. It passes--short=feature%2Fxtokosli versionand checks the error keeps%2F.-vet=off):invalid argument "feature%!F(MISSING)x".go vet,go testand golangci-lint.Full suite run locally against a local server: 3637 tests, all green.
🤖 Generated with Claude Code