mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-20 22:21:21 +00:00
Fixes #17821 The `is_cached_message` function crashed with TypeError when message content was a string instead of a list of content blocks. Changes: - Add explicit `isinstance(content, list)` check before iteration - Add `isinstance(content_item, dict)` check inside loop to skip non-dict items - Use `.get()` for safer nested dict access - Follow same pattern as `extract_ttl_from_cached_messages` (same module) Tests: - Add TestIsCachedMessage class with 9 test cases covering: - String content (the reported bug) - None content - Missing content key - Empty list content - List with/without cache_control - Mixed content types (strings + dicts) - Wrong cache_control type
Testing for litellm/
This directory 1:1 maps the the litellm/ directory, and can only contain mocked tests.
The point of this is to:
- Increase test coverage of
litellm/ - Make it easy for contributors to add tests for the
litellm/package and easily run tests without needing LLM API keys.
File name conventions
litellm/proxy/test_caching_routes.pymaps tolitellm/proxy/caching_routes.pytest_<filename>.pymaps tolitellm/<filename>.py