[Bugfix] Missing Content Type returns 500 Internal Server Error (#13193)

This commit is contained in:
Vaibhav Jain
2025-02-13 20:22:22 +05:30
committed by GitHub
parent 1bc3b5e71b
commit 37dfa60037
2 changed files with 43 additions and 15 deletions

View File

@@ -156,3 +156,19 @@ async def test_request_cancellation(server: RemoteOpenAIServer):
max_tokens=10)
assert len(response.choices) == 1
@pytest.mark.asyncio
async def test_request_wrong_content_type(server: RemoteOpenAIServer):
chat_input = [{"role": "user", "content": "Write a long story"}]
client = server.get_async_client()
with pytest.raises(openai.APIStatusError):
await client.chat.completions.create(
messages=chat_input,
model=MODEL_NAME,
max_tokens=10000,
extra_headers={
"Content-Type": "application/x-www-form-urlencoded"
})