mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-11 07:05:00 +00:00
f8e7e153d5
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
In total litellm runs 1000+ tests
[02/20/2025] Update:
To make it easier to contribute and map what behavior is tested,
we've started mapping the litellm directory in tests/test_litellm
This folder can only run mock tests.