From a8fbf2b340de73f9c50da01001e0d41db5904cee Mon Sep 17 00:00:00 2001 From: vvanglro <947001731@qq.com> Date: Fri, 4 Nov 2022 16:56:43 +0800 Subject: [PATCH] fix: request / router KeyError --- fastapi_cache/decorator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastapi_cache/decorator.py b/fastapi_cache/decorator.py index 0aea981..fb08e00 100644 --- a/fastapi_cache/decorator.py +++ b/fastapi_cache/decorator.py @@ -78,9 +78,9 @@ def cache( # if the wrapped function does NOT have request or response in its function signature, # make sure we don't pass them in as keyword arguments if not request_param: - kwargs.pop("request") + kwargs.pop("request", None) if not response_param: - kwargs.pop("response") + kwargs.pop("response", None) if inspect.iscoroutinefunction(func): # async, return as is.