litellm/tests/unit/llms/sagemaker
linhqm 42eeda8546
fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame (#53482)
* fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame

SageMaker streaming (sagemaker and sagemaker_chat) and Bedrock invoke-agent turned an HTTP 200 whose
event-stream body decoded to no events, or ended with bytes that never formed a whole frame, into an
empty successful turn. They now raise a 502 naming the content type, the x-amzn-requestid, and the byte
count, through the same tally the Bedrock converse and invoke decoders use, so router retries and
fallbacks apply.

Invoke-agent exception frames now raise with the status the bedrock-agent-runtime model gives them
instead of being dropped, and error frames keep their error code and message.

* fix(bedrock,sagemaker): keep body bytes out of the 502 and retry agent error frames

The no-events 502 now names the content-type, request id and byte count only, since a cut frame can hold model text that skips message redaction. Untyped error frames on Bedrock agents answer 500 so the router retries them, and Bedrock chat keeps its body-only error text for those frames, as on main

* fix(bedrock,sagemaker): answer 502 naming the request when a 200 body is not an AWS event stream

* fix(bedrock): answer 502 when a Bedrock /v1/messages stream stops decoding

The Rust Messages route now ends a 200 Bedrock stream whose body is not an AWS event stream, or turns corrupt after some events, with the same 502 Python's decoder gives, naming the botocore parser error class instead of a bare checksum mismatch.

* test(bedrock): table the Rust invoke stream 502 cases and assert facts, not message text

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-22 23:59:32 +00:00
..
__init__.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_sagemaker_chat_handler.py refactor(sdk): separate core AWS and tokenizer dependencies (#44447) 2026-10-08 19:07:57 -07:00
test_sagemaker_chat_transformation.py fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame (#53482) 2026-11-22 23:59:32 +00:00
test_sagemaker_common_utils.py fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame (#53482) 2026-11-22 23:59:32 +00:00
test_sagemaker_completion_handler.py fix(sagemaker,bedrock): answer 502 when a 200 AWS event stream decodes to no events or ends mid-frame (#53482) 2026-11-22 23:59:32 +00:00
test_sagemaker_embedding_openai.py feat(sagemaker)!: inference components and OpenAI-compatible embeddings (#44985) 2026-10-12 22:25:52 +00:00
test_sagemaker_embedding_role_assumption.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_sagemaker_embedding_voyage.py fix(bedrock): send max_tokens and priority in Cohere embedding requests (#51435) 2026-11-12 23:44:08 +00:00
test_sagemaker_nova_transformation.py fix(streaming)!: send the include_usage chunk with an empty choices array (#47109) 2026-10-21 02:26:05 +00:00