litellm/tests/unit/proxy/anthropic_endpoints
paveln83 0021d5493c
fix(bedrock): answer 400, not 500, for malformed count-tokens requests (#50708)
* fix(bedrock): answer 400, not 500, for malformed native count-tokens requests

The Bedrock count-tokens handler now checks the body before any AWS call and raises a 400 BedrockError for a missing or empty messages list, a message without role or content, or a missing model. The token counter marks that rejection as local, so it skips the Mantle fallback and the framing estimate, and /v1/messages/count_tokens answers invalid_request_error

get_bedrock_base_model returns a bare cross-region prefix such as us or global unchanged instead of raising IndexError, so Bedrock judges the model id and its own 400 reaches the caller

* fix(bedrock): answer 400 for a malformed message on Mantle token counts

* fix(bedrock): limit the region-only model id fix to token counting

* fix(bedrock): count a routing-prefixed region-only id and leave other providers' count errors as they were

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-09 23:04:36 +00:00
..
__init__.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_answered_status.py fix(anthropic): answer an upstream Anthropic 529 as 529 overloaded_error on /v1/messages (#46063) 2026-11-03 17:37:09 -08:00
test_claude_code_marketplace.py feat(skills): add sortable Skills Hub catalog and publication audit (#50195) 2026-11-06 00:57:33 +00:00
test_claude_code_skill_access.py feat(access-groups): grant Claude Code skills through access groups (#46294) 2026-10-14 23:18:50 +00:00
test_endpoints.py fix(bedrock): answer 400, not 500, for malformed count-tokens requests (#50708) 2026-11-09 23:04:36 +00:00
test_gateway_endpoints.py feat(proxy): let a Claude Code gateway user choose the session team (#49001) 2026-10-29 03:47:27 -07:00
test_skill_upload_archive.py test(skills): drop the archive rejection test whose zip-byte ids differ across xdist workers (#50118) 2026-11-04 22:12:55 +00:00
test_skills_endpoints.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_streaming_model_restamp.py fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00