cashews icon indicating copy to clipboard operation
cashews copied to clipboard

Fix IndexError in CacheEtagMiddleware

Open harry-patcher opened this issue 7 months ago β€’ 0 comments

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 πŸ“¬.

harry-patcher avatar May 20 '25 21:05 harry-patcher