mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-28 06:23:07 +00:00
test(proxy): pin the mid-stream failure frame and the DB outage body to a JSON null param
Some checks failed
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Some checks failed
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
This commit is contained in:
parent
d80b6a9792
commit
17a86d7b2c
2 changed files with 34 additions and 1 deletions
|
|
@ -438,7 +438,7 @@ _DB_OUTAGE_503_BODY: Final = {
|
|||
"error": {
|
||||
"message": "Service Unavailable, the authentication database is temporarily unreachable. Please retry shortly.",
|
||||
"type": "no_db_connection",
|
||||
"param": "None",
|
||||
"param": None,
|
||||
"code": "503",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7250,6 +7250,39 @@ async def test_async_data_generator_closes_the_guardrail_chain_before_returning_
|
|||
assert cleanup_ran == [True]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_data_generator_midstream_failure_frame_is_openai_shaped_with_a_json_null_param():
|
||||
from litellm.proxy._types import UserAPIKeyAuth
|
||||
from litellm.proxy.proxy_server import async_data_generator
|
||||
|
||||
async def chain_failing_after_first_chunk(**_kwargs):
|
||||
yield {"choices": [{"delta": {"content": "Hello"}}]}
|
||||
raise ValueError("audit hook could not reach its sink")
|
||||
|
||||
proxy_logging = _guarded_chain_logging(chain_failing_after_first_chunk)
|
||||
proxy_logging.post_call_failure_hook = AsyncMock(return_value=None)
|
||||
|
||||
with patch("litellm.proxy.proxy_server.proxy_logging_obj", proxy_logging):
|
||||
frames = [
|
||||
frame
|
||||
async for frame in async_data_generator(
|
||||
MagicMock(), MagicMock(spec=UserAPIKeyAuth), {"model": "gpt-4o-mini"}
|
||||
)
|
||||
]
|
||||
|
||||
error_bodies = [json.loads(frame.removeprefix("data: ")) for frame in frames if '"error"' in frame]
|
||||
assert error_bodies == [
|
||||
{
|
||||
"error": {
|
||||
"message": "audit hook could not reach its sink",
|
||||
"type": "internal_server_error",
|
||||
"param": None,
|
||||
"code": "500",
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_data_generator_closes_the_guardrail_chain_while_a_keepalive_read_is_pending():
|
||||
from litellm.proxy._types import UserAPIKeyAuth
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue