Skip to content

Conversation

@mivehk
Copy link
Contributor

@mivehk mivehk commented Dec 11, 2025

Purpose

Strengthening the input validation tests for parse_raw_prompts, raising the TypeError when mix of strings and tokens, or array of array of strings are used as input.

Test Plan

pytest tests/inputs/test_inputs.py
New test case is passed for cpu only execution.

Test Result

All tests will be passed, including the newly added test case raising 'TypeError'

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

@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 ask your reviewers to trigger select CI tests on top of fastcheck CI.

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.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

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 correctly adds tests for invalid inputs to parse_raw_prompts that should raise a TypeError. While reviewing, I found a related validation bug where partially empty batches like [[1], []] are incorrectly accepted. I've added a comment suggesting a new test case to expose this issue, which would further improve the robustness of the input parsing.

Comment on lines 36 to 45
@pytest.mark.parametrize(
"invalid_input",
[
["foo", 1], # mixed of string and token
[["foo"], ["bar"]] # list of list of strings
]
)
def test_invalid_input_raise_type_error(invalid_input):
with pytest.raises(TypeError):
parse_raw_prompts(invalid_input)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This is a good addition for testing TypeError cases. While reviewing this, I noticed a potential logic issue in parse_raw_prompts that isn't covered.

The function currently only checks if the first sublist is empty for list[list[int]] style inputs. This means an input like [[1], []] would be accepted, which is inconsistent with the fact that [[]] correctly raises a ValueError.

This could lead to unexpected behavior with partially empty batch prompts.

I'd recommend adding another test to assert that prompts containing empty sublists also raise a ValueError. Since this test is focused on TypeError, a new test function would be appropriate. For example:

def test_parse_raw_list_of_list_with_empty_sublist():
    with pytest.raises(ValueError, match="at least one prompt"):
        parse_raw_prompts([[1], []])

Adding this test would expose the issue and allow for a fix in parse_raw_prompts.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 39 to 43
["foo", 1], # mixed of string and token
[["foo"], ["bar"]] # list of list of strings
]
)
def test_invalid_input_raise_type_error(invalid_input):

Choose a reason for hiding this comment

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

P1 Badge New invalid-input test fails with current parser logic

The new test_invalid_input_raise_type_error expects ["foo", 1] to trigger a TypeError, but parse_raw_prompts currently checks only the first element of a list (is_list_of(prompt, str) at vllm/inputs/parse.py:36) and treats such input as an array of strings, returning TextPrompt objects instead of raising. With the existing implementation, this test will deterministically fail whenever the suite runs against a mixed string/int list.

Useful? React with 👍 / 👎.

@mergify
Copy link

mergify bot commented Dec 11, 2025

Hi @mivehk, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

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

Thanks for adding the test, see if it passes

@DarkLight1337
Copy link
Member

Also please fix pre-commit

@mergify
Copy link

mergify bot commented Dec 11, 2025

Hi @mivehk, the pre-commit checks have failed. Please run:

uv pip install pre-commit
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy or markdownlint failing?
mypy and markdownlint are run differently in CI. If the failure is related to either of these checks, please use the following commands to run them locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
# For markdownlint
pre-commit run --hook-stage manual markdownlint

@mivehk
Copy link
Contributor Author

mivehk commented Dec 11, 2025

Hi,
Thanks for reviewing my pull request and your guidance. I installed uv and pre-commit, so I will open a new pull request from an updated branch with the revised input-validation test. I appreciate your time and feedback.

@DarkLight1337
Copy link
Member

Closing as superseded by #30512

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.

2 participants