fix(FLEETMDM-004): fmt.Sprintf used to build log message string instead of structured key-value logging - #127
Draft
flamingo[bot] wants to merge 1 commit into
Draft
Conversation
…ad of structured key-value logging
Comment on lines
43
to
50
| ) | ||
|
|
||
| if err := server.PostJSONWithTimeout(ctx, w.url, payload, w.logger); err != nil { | ||
| w.logger.ErrorContext(ctx, fmt.Sprintf("failed to send automation webhook to %s", server.MaskSecretURLParams(w.url)), | ||
| w.logger.ErrorContext(ctx, "failed to send automation webhook", | ||
| "url", server.MaskSecretURLParams(w.url), | ||
| "err", server.MaskURLError(err).Error(), | ||
| ) | ||
| } |
Author
There was a problem hiding this comment.
🦩 🔴 fmt.Sprintf used to build log message string instead of structured key-value logging
In webhookLogWriter.Write, replaced the fmt.Sprintf-interpolated error log message with a static message "failed to send automation webhook" and added "url" as a separate structured key-value pair alongside the existing "err" key; removed the now-unused "fmt" import since it was only used for this Sprintf call.
🤖 Prompt for AI agents
In server/logging/webhook.go around line 35, review and complete this code-review fix: fmt.Sprintf used to build log message string instead of structured key-value logging.
What the draft fix changed: In webhookLogWriter.Write, replaced the fmt.Sprintf-interpolated error log message with a static message "failed to send automation webhook" and added "url" as a separate structured key-value pair alongside the existing "err" key; removed the now-unused "fmt" import since it was only used for this Sprintf call.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer
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.
Closes findings from rule FLEETMDM-004 — fmt.Sprintf used to build log message string instead of structured key-value logging.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
server/logging/webhook.go:35What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
f6d23861-693f-45a1-b5b3-570aa3bc9ea7Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.