From 98bcc6ca593293cf650699e54e499e7189c24ac1 Mon Sep 17 00:00:00 2001 From: Andreas Karatzas Date: Sun, 15 Feb 2026 01:08:38 -0600 Subject: [PATCH] [CI][Entrypoints] Validate detokenize token IDs to prevent int64 overflow causing 500 (#34468) Signed-off-by: Andreas Karatzas --- vllm/entrypoints/serve/tokenize/protocol.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vllm/entrypoints/serve/tokenize/protocol.py b/vllm/entrypoints/serve/tokenize/protocol.py index 39b181aa7..a2bdd3c20 100644 --- a/vllm/entrypoints/serve/tokenize/protocol.py +++ b/vllm/entrypoints/serve/tokenize/protocol.py @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project -from typing import Any, TypeAlias +from typing import Annotated, Any, TypeAlias from pydantic import ConfigDict, Field, model_validator @@ -156,7 +156,10 @@ class TokenizeResponse(OpenAIBaseModel): class DetokenizeRequest(OpenAIBaseModel): model: str | None = None - tokens: list[int] + # TODO: Factor `torch.iinfo` out. `torch.iinfo` pulls torch into a + # Pydantic protocol file that currently has no torch dependency. + # See: https://github.com/vllm-project/vllm/pull/34468#discussion_r2801173630 + tokens: list[Annotated[int, Field(ge=0, le=2**63 - 1)]] def build_tok_params(self, model_config: ModelConfig) -> TokenizeParams: return TokenizeParams(