[Bugfix] reject string file on translation like transcription (#55618)
Signed-off-by: oskii <oscarchambersweb@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Dev Oskii committed
Sep 8, 2026 at 06:02 UTC
6c73b08dec2af5052288169663549687ba61f330
1 file changed
+7
-1
vllm/entrypoints/speech_to_text/translation/protocol.py
+7
-1
@@ -3,9 +3,10 @@
3
4
import json
5
import time
6
+from http import HTTPStatus
7
from typing import TYPE_CHECKING, Literal, TypeAlias
8
8
-from fastapi import UploadFile
9
+from fastapi import HTTPException, UploadFile
10
from pydantic import (
11
Field,
12
model_validator,
@@ -270,6 +271,11 @@ class TranslationRequest(OpenAIBaseModel):
271
def validate_stream_options(cls, data):
272
if not isinstance(data, dict):
273
return data
274
+ if isinstance(data.get("file"), str):
275
+ raise HTTPException(
276
+ status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
277
+ detail="Expected 'file' to be a file-like object, not 'str'.",
278
+ )
279
stream_opts = ["stream_include_usage", "stream_continuous_usage_stats"]
280
stream = data.get("stream", False)
281
if any(bool(data.get(so, False)) for so in stream_opts) and not stream: