fix(responses): preserve delete error status

This commit is contained in:
hogeheer 2026-07-24 00:24:20 +02:00
parent 43e7b96b83
commit f4b9357d53
No known key found for this signature in database
2 changed files with 27 additions and 0 deletions

View file

@ -465,6 +465,8 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
"""
Transform the delete response API response into a DeleteResponseResult
"""
if not raw_response.is_success:
raise OpenAIError(message=raw_response.text, status_code=raw_response.status_code)
try:
raw_response_json = raw_response.json()
except Exception:

View file

@ -13,6 +13,7 @@ sys.path.insert(
import litellm
from litellm.llms.base_llm.responses.transformation import BaseResponsesAPIConfig
from litellm.llms.azure.responses.transformation import AzureOpenAIResponsesAPIConfig
from litellm.llms.openai.common_utils import OpenAIError
from litellm.llms.openai.responses.transformation import OpenAIResponsesAPIConfig
from litellm.types.llms.openai import (
ImageGenerationPartialImageEvent,
@ -44,6 +45,30 @@ class TestOpenAIResponsesAPIConfig:
# The function should return the params unchanged
assert result == test_params
@pytest.mark.parametrize(
"config",
[OpenAIResponsesAPIConfig(), AzureOpenAIResponsesAPIConfig()],
)
def test_delete_response_preserves_not_found_status(self, config):
response = httpx.Response(
status_code=404,
json={
"error": {
"message": "Response not found",
"type": "invalid_request_error",
}
},
request=httpx.Request("DELETE", "https://example.com/v1/responses/resp_missing"),
)
with pytest.raises(OpenAIError) as exc_info:
config.transform_delete_response_api_response(
raw_response=response,
logging_obj=self.logging_obj,
)
assert exc_info.value.status_code == 404
@pytest.mark.parametrize("max_output_tokens", [1, 15])
def test_map_openai_params_clamps_max_output_tokens_below_minimum(self, max_output_tokens):
"""OpenAI's Responses API rejects max_output_tokens < 16.