Skip to content

[CI][Frontend] Return 422 instead of 500 for invalid Anthropic tool_choice#34590

Merged
vllm-bot merged 1 commit intovllm-project:mainfrom
ROCm:akaratza_entrypoints_server_api_i
Feb 16, 2026
Merged

[CI][Frontend] Return 422 instead of 500 for invalid Anthropic tool_choice#34590
vllm-bot merged 1 commit intovllm-project:mainfrom
ROCm:akaratza_entrypoints_server_api_i

Conversation

@AndreasKaratzas
Copy link
Collaborator

@AndreasKaratzas AndreasKaratzas commented Feb 15, 2026

When tool_choice is {"type": "tool"} without a name, the /v1/messages endpoint crashes with a 500 Internal Server Error. This happens because _convert_anthropic_to_openai_request passes name=None to ChatCompletionNamedToolChoiceParam, which fails Pydantic validation as an unhandled exception.

The Anthropic API spec requires name when tool_choice.type is "tool". This PR adds a model_validator to AnthropicToolChoice so the constraint is enforced at request parsing time, producing a proper 422 validation error instead of a 500.

Also adds the /v1/messages endpoint to the longer timeout map in the schema test, since it is a completion endpoint.

Motivation

AMD nightly CI: https://buildkite.com/vllm/amd-ci/builds/4788/steps/canvas?sid=019c6019-8f6f-4b50-a415-c3f443c97c5e&tab=output
schemathesis property-based testing in test_openapi_stateless[POST /v1/messages].

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
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 addresses a 500 Internal Server Error that occurred with invalid tool_choice parameters in the Anthropic API compatibility layer. The introduction of a model_validator in AnthropicToolChoice is a clean and effective way to enforce the API contract at the request parsing stage, properly returning a 422 validation error instead of crashing. The associated change to extend the timeout for the /v1/messages endpoint in the schema tests is also appropriate, aligning it with other completion endpoints. The changes are well-targeted and improve the robustness of the server. Good work.

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) February 16, 2026 02:21
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 16, 2026
@vllm-bot vllm-bot merged commit 974d829 into vllm-project:main Feb 16, 2026
50 of 52 checks passed
@AndreasKaratzas AndreasKaratzas deleted the akaratza_entrypoints_server_api_i branch February 16, 2026 04:12
stmoonar pushed a commit to stmoonar/vllm that referenced this pull request Feb 16, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: stmoonar <xx0294432@gmail.com>
athrael-soju pushed a commit to athrael-soju/vllm that referenced this pull request Feb 16, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: athrael-soju <athrael-soju@users.noreply.github.com>
wzhao18 pushed a commit to wzhao18/vllm that referenced this pull request Feb 18, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: wzhao18 <wzhao18.sz@gmail.com>
eldarkurtic pushed a commit to eldarkurtic/vllm that referenced this pull request Feb 19, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: Eldar Kurtic <research@neuralmagic.com>
ZJY0516 pushed a commit to ZJY0516/vllm that referenced this pull request Feb 23, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
llsj14 pushed a commit to llsj14/vllm that referenced this pull request Mar 1, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
tunglinwood pushed a commit to tunglinwood/vllm that referenced this pull request Mar 4, 2026
…hoice (vllm-project#34590)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants