fix: prevent fmt.Sprintf from mangling % characters in plan output#2616
Open
m-agahi wants to merge 2 commits intodiggerhq:developfrom
Open
fix: prevent fmt.Sprintf from mangling % characters in plan output#2616m-agahi wants to merge 2 commits intodiggerhq:developfrom
m-agahi wants to merge 2 commits intodiggerhq:developfrom
Conversation
GetTerraformOutputAsCollapsibleComment and AsCollapsibleComment embed the comment and summary strings directly into the fmt.Sprintf format string. Any % characters in the content (e.g. MySQL wildcard host "10.%" or random_password override_special strings) get interpreted as format verbs, producing %!(MISSING) / %!(BADWIDTH) in the output. Fix by passing summary and comment as explicit %s arguments instead.
…ters Tests verify that GetTerraformOutputAsCollapsibleComment and AsCollapsibleComment do not mangle % characters in comments or summaries (e.g. MySQL wildcard host 10.%, override_special with %).
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.
🧠 Ai UsageDetails (if applicable):
This PR was written with the assistance of Claude Code (code fix, tests, and PR description generated by Claude Code, reviewed manually).
Problem
GetTerraformOutputAsCollapsibleCommentandAsCollapsibleCommentembed thecommentandsummarystrings directly into the format string passed tofmt.Sprintf. Any%characters in the content get interpreted as format verbs, producing%!(MISSING)/%!(BADWIDTH)in the output.Real-world examples that trigger this:
10.%inmysql_user/mysql_grantresource addressesoverride_special = "~!#%^&*()..."inrandom_passwordresourcesBefore (broken):
After (fixed):
Changes
GetTerraformOutputAsCollapsibleComment: passsummaryandcommentas%sarguments instead of interpolating into the format stringAsCollapsibleComment: same fix%in comments,%in summaries, and open/closed tag behaviorGetTerraformOutputAsCommentandAsCommentuse string concatenation (notfmt.Sprintf) so they are unaffected.Test plan
go test -v ./libs/comment_utils/reporting/— all 7 tests pass%!(MISSING)errors, confirming they catch the bug