Skip to content

fix: escape % in help text#18

Open
KiruyaMomochi wants to merge 1 commit intokvcache-ai:mainfrom
KiruyaMomochi:patch-1
Open

fix: escape % in help text#18
KiruyaMomochi wants to merge 1 commit intokvcache-ai:mainfrom
KiruyaMomochi:patch-1

Conversation

@KiruyaMomochi
Copy link
Copy Markdown

Motivation

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/root/sglang/.venv/lib/python3.11/site-packages/sglang/launch_server.py", line 29, in <module>
    server_args = prepare_server_args(sys.argv[1:])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/sglang/.venv/lib/python3.11/site-packages/sglang/srt/server_args.py", line 5145, in prepare_server_args
    raw_args = parser.parse_args(argv)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 1877, in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 1910, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 2131, in _parse_known_args
    start_index = consume_optional(start_index)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 2071, in consume_optional
    take_action(action, args, option_string)
  File "/opt/conda/lib/python3.11/argparse.py", line 1986, in take_action
    action(self, namespace, argument_values, option_string)
  File "/opt/conda/lib/python3.11/argparse.py", line 1125, in __call__
    parser.print_help()
  File "/opt/conda/lib/python3.11/argparse.py", line 2614, in print_help
    self._print_message(self.format_help(), file)
                        ^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 2598, in format_help
    return formatter.format_help()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 288, in format_help
    help = self._root_section.format_help()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 218, in format_help
    item_help = join([func(*args) for func, args in self.items])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 218, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
                      ^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 218, in format_help
    item_help = join([func(*args) for func, args in self.items])
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 218, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
                      ^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 547, in _format_action
    help_text = self._expand_help(action)
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/argparse.py", line 646, in _expand_help
    return self._get_help_string(action) % params
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
TypeError: %c requires int or char

Modifications

Replace % with %%.

Accuracy Tests

Benchmarking and Profiling

Checklist

Review Process

  1. Ping Merge Oncalls to start the PR flow. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • /tag-run-ci-label, /rerun-failed-ci, /tag-and-rerun-ci
  4. After green CI and required approvals, ask Merge Oncalls to merge.

@KiruyaMomochi KiruyaMomochi changed the title fix: escape % in help test fix: escape % in help text Jan 23, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @KiruyaMomochi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where the application would crash with a TypeError when displaying help messages due to an unescaped percentage sign in an argument's help text. The fix involves correctly escaping the problematic character, ensuring that the help documentation can be rendered and viewed without errors, thereby improving the robustness of the command-line interface.

Highlights

  • Bug Fix: Resolved a TypeError: %c requires int or char that occurred when argparse attempted to display help messages containing an unescaped percentage sign.
  • Help Message Formatting: Escaped the literal '%' character to '%%' within the help string for the --nsa-prefill-cp-mode argument to prevent it from being misinterpreted as a format specifier.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a TypeError that occurs when using the --help command-line argument. The issue was caused by an unescaped percentage sign in an argparse help string, which was being misinterpreted as a format specifier. The fix properly escapes the character by changing % to %%, which resolves the crash. The change is accurate and effective. I have reviewed the modified file for other similar instances and found no further issues. This is a good fix.

ErvinXie pushed a commit that referenced this pull request Feb 26, 2026
sgl-project#18739)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: 赵晨阳 <zhaochen20@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant