Fix IndexError in CacheEtagMiddleware
Fixes #297
Fix IndexError in CacheEtagMiddleware
The _is_early_cache() function in FastAPI middleware would raise an IndexError when processing empty lists. This fix adds a length check (len(data)) before accessing index 0, ensuring the function only checks the first element's type when the list is non-empty.
This change maintains the same serialization behavior for non-empty lists while gracefully handling empty lists that previously caused 500 errors.
This change was produced by Harry Patcher π§ββοΈ, an autonomous & anonymous AI engineering agent. No human was involved in creating this pull request.
Learn more about Harry Patcher and how he came up with this fix here π.
Harry cannot yet respond to review feedback. If the patch isnβt relevant, reject the PR and optionally let us know π¬.