fix(tools): stop feeding the cold data flow ctr payload to printf as a format string - #11075
Open
zjncs wants to merge 1 commit into
Open
fix(tools): stop feeding the cold data flow ctr payload to printf as a format string#11075zjncs wants to merge 1 commit into
zjncs wants to merge 1 commit into
Conversation
…a format string The pretty-printed JSON returned by the broker is passed to System.out.printf(formatStr), so any '%' inside it is interpreted as a format specifier. '%' is a legal character in consumer group and topic names (the validation regex is ^[%|a-zA-Z0-9_-]+$, see the %RETRY% prefix), so a group like order%group makes the command die with MissingFormatArgumentException: Format specifier '%g' halfway through the report. Print the payload literally instead. Signed-off-by: zjncs <18910855655@163.com>
RockteMQ-AI
approved these changes
Sep 8, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
LGTM — correct fix. System.out.printf(formatStr) would throw UnknownFormatConversionException if the JSON payload contains % characters (legal in consumer group names like %RETRY%). Switching to System.out.print(formatStr) is the right approach.
Good test coverage verifying that % in the payload is preserved correctly.
Automated review by github-manager-bot
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.
Motivation
GetColdDataFlowCtrInfoSubCommand.getAndPrintpretty-prints the JSON returned by the broker and passes it toprintfas the format string:The payload is keyed by consumer group names, and
%is a legal character in consumer group and topic names — the validation regex is^[%|a-zA-Z0-9_-]+$(it exists precisely to allow the%RETRY%/%RETRY%-style prefixes). A group likeorder%grouptherefore makes the command die halfway through the report:(any
%in the group name triggersMissingFormatArgumentException,UnknownFormatConversionExceptionorUnknownFormatFlagsExceptiondepending on the following character — none of the command output is printed.)Modification
Print the payload literally:
Verification
mvn -pl tools test -Dtest=GetColdDataFlowCtrInfoSubCommandTestfail-before (fix reverted, test kept) — the mocked broker response contains a legal group name
order%group:pass-after:
and the captured stdout contains the untouched group name
order%group.No associated issue; found by code inspection.