mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
test(integration): send OpenAI-shaped error types from the fake upstream
Some checks failed
Some checks failed
Since #40994 the proxy relays the upstream error body on a 400, so the public error type is now whatever the upstream sent instead of the status-derived name. The fake upstream answered every scripted failure with type api_error, which made the public-error contract in test_retry_counts_and_public_errors_match_actual_provider_attempts fail on main. The fake now sends the type a real OpenAI-compatible upstream sends for the status, so the assertion holds whether the proxy relays or maps the type
This commit is contained in:
parent
7679e42736
commit
fa5d31a837
1 changed files with 7 additions and 1 deletions
|
|
@ -31,6 +31,12 @@ INTERNAL_FIELDS: Final = frozenset(
|
|||
)
|
||||
|
||||
|
||||
def error_type(status: int) -> str:
|
||||
if status == 429:
|
||||
return "rate_limit_error"
|
||||
return "invalid_request_error" if status < 500 else "server_error"
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class Observation:
|
||||
path: str
|
||||
|
|
@ -66,7 +72,7 @@ class Provider:
|
|||
status: Final = script.popleft()
|
||||
if status != 200:
|
||||
return JSONResponse(
|
||||
{"error": {"message": "Controlled provider failure", "type": "api_error", "code": str(status)}},
|
||||
{"error": {"message": "Controlled provider failure", "type": error_type(status), "code": str(status)}},
|
||||
status_code=status,
|
||||
)
|
||||
return await chat_completions(request)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue