mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(proxy): return 400 when 'input' is omitted in POST /v1/responses
Closes #41159
This commit is contained in:
parent
9496f16f12
commit
e2aff27221
2 changed files with 31 additions and 0 deletions
|
|
@ -245,6 +245,12 @@ async def responses_api(
|
|||
|
||||
data = await _read_request_body(request=request)
|
||||
|
||||
if "input" not in data:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail={"error": "input parameter is required"},
|
||||
)
|
||||
|
||||
# Check if polling via cache should be used for this request
|
||||
from litellm.proxy.response_polling.polling_handler import (
|
||||
should_use_polling_for_request,
|
||||
|
|
|
|||
|
|
@ -55,6 +55,31 @@ class TestResponsesAPIEndpoints(unittest.TestCase):
|
|||
|
||||
assert response.status_code in [200, 401, 500]
|
||||
|
||||
@patch("litellm.proxy.proxy_server.llm_router")
|
||||
@patch("litellm.proxy.proxy_server.user_api_key_auth")
|
||||
def test_openai_v1_responses_missing_input_raises_400(self, mock_auth, mock_router):
|
||||
"""
|
||||
Test that /openai/v1/responses returns 400 when 'input' is missing (Issue #41159).
|
||||
"""
|
||||
mock_auth.return_value = MagicMock(
|
||||
token="test_token",
|
||||
user_id="test_user",
|
||||
team_id=None,
|
||||
)
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
test_data = {"model": "gpt-4o"}
|
||||
|
||||
response = client.post(
|
||||
"/openai/v1/responses",
|
||||
json=test_data,
|
||||
headers={"Authorization": "Bearer sk-1234"},
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
assert "input" in response.text.lower()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("litellm.proxy.proxy_server.llm_router")
|
||||
@patch("litellm.proxy.proxy_server.user_api_key_auth")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue