You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using cashews in my fastapi application and whenever the endpoint returns an empty list, CacheEtagMiddleware wont be able to serialize it, resulting in IndexError: list index out of range.
_is_early_cache() should be "return isinstance(data, list) and len(data) and isinstance(data[0], datetime) "
def _get_etag(cached_data: Any) -> str:
if _is_early_cache(cached_data):
cached_data = cached_data[1]
if not isinstance(cached_data, bytes):
cached_data = cached_data.body if isinstance(cached_data, Response) else DEFAULT_PICKLER.dumps(cached_data)
return blake2s(cached_data).hexdigest()
I am using cashews in my fastapi application and whenever the endpoint returns an empty list, CacheEtagMiddleware wont be able to serialize it, resulting in IndexError: list index out of range.
_is_early_cache() should be "return isinstance(data, list) and len(data) and isinstance(data[0], datetime) "
def _get_etag(cached_data: Any) -> str:
if _is_early_cache(cached_data):
cached_data = cached_data[1]
if not isinstance(cached_data, bytes):
cached_data = cached_data.body if isinstance(cached_data, Response) else DEFAULT_PICKLER.dumps(cached_data)
return blake2s(cached_data).hexdigest()
def _is_early_cache(data: Any) -> bool:
return isinstance(data, list) and isinstance(data[0], datetime)
The text was updated successfully, but these errors were encountered: