Skip to content

Conversation

@ranpox
Copy link
Contributor

@ranpox ranpox commented Jul 22, 2025

Edit from @simon-mo

Tested locally for both tool use example and unit test.

image

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

Copy link
Contributor

@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 introduces a new tool parser for Qwen3 Coder's XML format. The implementation is comprehensive, covering both streaming and non-streaming modes. However, I've identified a critical security vulnerability with the use of eval() on model output, which must be addressed. I've also pointed out several high-severity issues related to exception handling and unsafe string operations that could lead to crashes or hide bugs. Addressing these points will significantly improve the robustness and security of the new parser.

Comment on lines 194 to 199
try:
param_value = eval(param_value)
except:
logger.warning(
f"Parsed value '{param_value}' of parameter '{param_name}' cannot be converted via Python `eval()` in tool '{func_name}', degenerating to string."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The use of eval() on model-generated output is a critical security vulnerability as it can lead to arbitrary code execution. The model's output can be influenced by user input, creating a potential attack vector. Please remove eval() and rely on safer parsing methods. The existing logic will correctly fall back to returning the parameter as a string if other conversions fail.

):
try:
param_value = int(param_value)
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Avoid using bare except: clauses. They catch all exceptions, including SystemExit and KeyboardInterrupt, which can hide bugs and make the program difficult to terminate. Please catch a more specific exception, like ValueError in this case, which is raised by int() on conversion failure.

Suggested change
except:
except ValueError:

try:
float_param_value = float(param_value)
param_value = float_param_value if float_param_value - int(float_param_value) != 0 else int(float_param_value)
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Avoid using bare except: clauses. They catch all exceptions, including SystemExit and KeyboardInterrupt, which can hide bugs and make the program difficult to terminate. Please catch a more specific exception, like ValueError in this case, which is raised by float() on conversion failure.

Suggested change
except:
except ValueError:

try:
param_value = json.loads(param_value)
return param_value
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Avoid using bare except: clauses. They catch all exceptions, including SystemExit and KeyboardInterrupt, which can hide bugs and make the program difficult to terminate. Please catch a more specific exception, like json.JSONDecodeError in this case.

Suggested change
except:
except json.JSONDecodeError:

return param_value

# Extract function name
end_index = function_call_str.index(">")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using str.index() will raise a ValueError if the substring '>' is not found. This could cause an unhandled exception for malformed model output. It's safer to use str.find(), which returns -1 on failure. Please add a check for end_index == -1 to handle malformed input gracefully.

Suggested change
end_index = function_call_str.index(">")
end_index = function_call_str.find(">")

param_dict = {}
for match in self.tool_call_parameter_regex.findall(parameters):
match_text = match[0] if match[0] else match[1]
idx = match_text.index(">")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Using str.index() will raise a ValueError if the substring '>' is not found. This could cause an unhandled exception for malformed model output. It's safer to use str.find(), which returns -1 on failure. Please add a check for idx == -1 to handle malformed input gracefully.

Suggested change
idx = match_text.index(">")
idx = match_text.find(">")

content=content if content else None,
)

except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Catching a broad Exception can hide bugs and make debugging difficult. It's better to catch more specific exceptions that you expect to occur in the try block. Based on the code, ValueError from parsing errors is a likely candidate.

Suggested change
except Exception:
except ValueError:

@simon-mo simon-mo added this to the v0.10.0 milestone Jul 22, 2025
@simon-mo simon-mo changed the title Add Qwen3CoderToolParser [Model] Add Qwen3CoderToolParser Jul 22, 2025
Signed-off-by: simon-mo <[email protected]>
@simon-mo simon-mo marked this pull request as ready for review July 22, 2025 21:24
@simon-mo simon-mo requested a review from aarnphm as a code owner July 22, 2025 21:24
@simon-mo
Copy link
Collaborator

I'm force merging this to unblock model usage, after lint.

simon-mo added 2 commits July 22, 2025 14:45
Signed-off-by: simon-mo <[email protected]>
Signed-off-by: simon-mo <[email protected]>
@simon-mo simon-mo merged commit 4594fc3 into vllm-project:main Jul 22, 2025
7 of 9 checks passed
zixi-qi pushed a commit to zixi-qi/vllm that referenced this pull request Jul 23, 2025
Signed-off-by: simon-mo <[email protected]>
Co-authored-by: simon-mo <[email protected]>
Signed-off-by: qizixi <[email protected]>
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
Signed-off-by: simon-mo <[email protected]>
Co-authored-by: simon-mo <[email protected]>
Signed-off-by: x22x22 <[email protected]>
Pradyun92 pushed a commit to Pradyun92/vllm that referenced this pull request Aug 6, 2025
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
Signed-off-by: simon-mo <[email protected]>
Co-authored-by: simon-mo <[email protected]>
Signed-off-by: Jinzhen Lin <[email protected]>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
Signed-off-by: simon-mo <[email protected]>
Co-authored-by: simon-mo <[email protected]>
Signed-off-by: Paul Pak <[email protected]>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
Signed-off-by: simon-mo <[email protected]>
Co-authored-by: simon-mo <[email protected]>
Signed-off-by: Diego-Castan <[email protected]>
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend qwen Related to Qwen models tool-calling

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants