Files
litellm/tests/local_testing
Christian Reynoso HunterandGitHub e68cfaae0c fix(cache): Prevent "multiple values" error in get_cache_key (#20261)
## Problem

When `get_cache_key(**kwargs)` is called with kwargs that already
contains `preset_cache_key` (which can happen when cache key is
recomputed in certain code paths), the call to
`_set_preset_cache_key_in_kwargs()` fails with:

```
TypeError: _set_preset_cache_key_in_kwargs() got multiple values
for keyword argument 'preset_cache_key'
```

This is because `preset_cache_key` is passed both explicitly:
```python
self._set_preset_cache_key_in_kwargs(
    preset_cache_key=hashed_cache_key, **kwargs
)
```
And implicitly via `**kwargs` unpacking when `kwargs["preset_cache_key"]`
exists.

## Solution

Filter out `preset_cache_key` from kwargs before passing to
`_set_preset_cache_key_in_kwargs()`:

```python
kwargs_for_preset = {k: v for k, v in kwargs.items() if k != "preset_cache_key"}
self._set_preset_cache_key_in_kwargs(
    preset_cache_key=hashed_cache_key, **kwargs_for_preset
)
```

## Testing

Added unit tests covering:
- kwargs with existing preset_cache_key (the bug case)
- kwargs without preset_cache_key (regression test)
- Verification that preset_cache_key is correctly set in litellm_params
2026-04-04 18:40:56 -07:00
..
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 21:13:16 -07:00
2026-03-28 20:27:39 -07:00
2025-11-22 09:28:37 -08:00
fix
2026-03-30 21:33:47 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-30 21:07:49 -07:00
2026-03-28 19:17:38 -07:00
2026-03-30 16:24:35 -07:00
2026-03-30 17:53:26 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2026-03-28 19:17:38 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-10-25 10:19:24 -07:00
2025-09-01 17:59:40 -07:00
2026-03-28 19:17:38 -07:00
2025-09-01 17:04:47 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2026-03-28 19:17:38 -07:00
2025-09-01 17:04:47 -07:00
2026-03-30 16:20:01 -07:00
2026-03-28 19:17:38 -07:00