Skip to content

[Misc] Use VLLMValidationError for user-facing errors in Responses harmony#37327

Open
umut-polat wants to merge 1 commit intovllm-project:mainfrom
umut-polat:fix/responses-harmony-validation
Open

[Misc] Use VLLMValidationError for user-facing errors in Responses harmony#37327
umut-polat wants to merge 1 commit intovllm-project:mainfrom
umut-polat:fix/responses-harmony-validation

Conversation

@umut-polat
Copy link
Copy Markdown
Contributor

Summary

Replace ValueError with VLLMValidationError for three user-input validation errors in the Responses API Harmony conversion layer. This adds the parameter field to error responses, helping API clients identify which part of their request is invalid.

Changed

  • Missing role key in chat-format message → parameter: "messages"
  • Invalid call_id reference in function_call_outputparameter: "input"
  • Unknown input type in previous response → parameter: "input"

Not changed

Internal processing errors (browser message parsing, unknown channel) are kept as ValueError since they indicate server-side issues rather than invalid user input.

This continues the effort from #36256, #35531, #35510 to use VLLMValidationError consistently across the frontend layer.

Copy link
Copy Markdown
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 replaces ValueError with VLLMValidationError for user-input validation errors in the Responses API Harmony conversion layer, adding a parameter field to error responses to help API clients identify invalid request parts. The changes involve modifying the _parse_chat_format_message and response_input_to_harmony functions to raise VLLMValidationError with specific parameter names when encountering invalid input, enhancing error reporting for API clients.

"""Parse an OpenAI chat-format dict into Harmony messages."""
role = chat_msg.get("role")
if role is None:
raise ValueError(f"Message has no 'role' key: {chat_msg}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This ValueError should be replaced with VLLMValidationError to provide more context about the error, as the pull request description indicates. The parameter field should be set to "messages" to indicate that the error is related to the messages input.

raise VLLMValidationError(
            f"Message has no 'role' key: {chat_msg}",
            parameter="messages",
        )

call_response = prev_response
break
if call_response is None:
raise ValueError(f"No call message found for {call_id}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This ValueError should be replaced with VLLMValidationError to provide more context about the error, as the pull request description indicates. The parameter field should be set to "input" to indicate that the error is related to the input parameter.

raise VLLMValidationError(
                f"No call message found for {call_id}",
                parameter="input",
            )

msg = msg.with_recipient(f"functions.{response_msg['name']}")
msg = msg.with_content_type("json")
else:
raise ValueError(f"Unknown input type: {response_msg['type']}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

This ValueError should be replaced with VLLMValidationError to provide more context about the error, as the pull request description indicates. The parameter field should be set to "input" to indicate that the error is related to the input parameter.

raise VLLMValidationError(
            f"Unknown input type: {response_msg['type']}",
            parameter="input",
        )

…rmony

Replace ValueError with VLLMValidationError for three user-input
validation errors in the Responses API Harmony conversion layer:

- Missing 'role' key in chat-format message (parameter: messages)
- Invalid call_id reference in function_call_output (parameter: input)
- Unknown input type in previous response (parameter: input)

These errors are triggered by malformed user input. Using
VLLMValidationError provides the parameter field in the error
response, helping API clients identify which part of their request
is invalid.

Internal processing errors (browser message parsing, unknown
channel) are kept as ValueError since they indicate server-side
issues rather than invalid user input.

Signed-off-by: umut-polat <52835619+umut-polat@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend gpt-oss Related to GPT-OSS models

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

1 participant