# RuntimeError: Dependency cache key must be hashable

- **ID:** `python/fastapi-runtimeerror-dependency-cache-key-must-be-hashable`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using a mutable object (like a list or dict) as a dependency parameter that FastAPI tries to cache.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Use immutable types like tuple instead of list.** (90% success)
   ```
   from typing import Tuple
async def dependency(items: Tuple[int, ...] = (1, 2, 3)):
    return items
   ```
2. **Use Pydantic models for complex parameters.** (95% success)
   ```
   from pydantic import BaseModel
class FilterParams(BaseModel):
    tags: list[str] = []

async def dependency(params: FilterParams):
    return params
   ```

## Dead Ends

- **Using a list as a default value for a dependency.** — Lists are mutable and unhashable, causing caching issues. (80% fail)
- **Using a dict as a query parameter.** — Query parameters must be hashable; dicts are not. (70% fail)
