[Frontend] Consolidate entrypoint exception handler (#52261)

Signed-off-by: wang.yuqi <yuqi.wang@daocloud.io>
This commit is contained in:
wang.yuqi
2026-08-14 09:27:24 +00:00
committed by GitHub
parent 103c419f04
commit b8165e5e58
31 changed files with 418 additions and 343 deletions
@@ -6,18 +6,10 @@ import pytest
from vllm.entrypoints.openai.engine.protocol import StreamOptions
from vllm.entrypoints.serve.utils.api_utils import (
get_max_tokens,
sanitize_message,
should_include_usage,
)
def test_sanitize_message():
assert (
sanitize_message("<_io.BytesIO object at 0x7a95e299e750>")
== "<_io.BytesIO object>"
)
@pytest.mark.parametrize(
("stream_options", "expected"),
[
@@ -118,49 +110,3 @@ class TestGetMaxTokens:
input_length=150,
default_sampling_params={"max_tokens": 2048},
)
class TestSanitizeMessageFilePaths:
"""sanitize_message should also strip file paths and traceback
frames, not just memory addresses - see #31683."""
def test_strips_traceback_style_frame(self):
msg = (
"1 validation error:\n"
" {'type': 'list_type', 'loc': ('body', 'messages')}\n"
'\n File "/usr/local/lib/python3.12/dist-packages/vllm/'
'entrypoints/serve/utils/api_utils.py", line 40, '
"in create_chat_completion\n"
" POST /v1/chat/completions"
)
result = sanitize_message(msg)
assert "/usr/local/" not in result
assert "api_utils.py" not in result
assert "list_type" in result
def test_strips_arbitrary_absolute_path(self):
result = sanitize_message("Error in /home/user/project/vllm/server.py")
assert "/home/user" not in result
def test_strips_single_parent_container_path(self):
"""Regression: /app/server.py and /workspace/server.py (common in
container deployments) were missed by the original {2,} quantifier."""
assert "/app/" not in sanitize_message("Error in /app/server.py")
assert "/workspace/" not in sanitize_message("Error in /workspace/server.py")
def test_preserves_api_endpoint_paths(self):
msg = "POST /v1/chat/completions failed"
assert "/v1/chat/completions" in sanitize_message(msg)
def test_preserves_short_field_references(self):
msg = "Invalid value for field 'body.messages'"
assert sanitize_message(msg) == msg
def test_strips_both_address_and_path(self):
msg = (
"<Request at 0x7f123> failed at "
"/usr/local/lib/python3.12/dist-packages/vllm/server.py"
)
result = sanitize_message(msg)
assert "0x" not in result
assert "/usr/local/" not in result