From 003209f830b4519bf634e2e1068412fb21f2a4af Mon Sep 17 00:00:00 2001 From: Jah-yee <166608075+Jah-yee@users.noreply.github.com> Date: Tue, 29 Sep 2026 20:11:35 +0800 Subject: [PATCH] fix(StateManager): catch TypeError in _decode_state for non-object JSON StateData(**state_dict) raises TypeError when state_dict is valid JSON but not a dict (e.g., a list [1, 2] or string "x"). Only ValueError was caught, leaving TypeError unhandled. Fixes: https://github.com/allen0099/FastAPI-CacheX/issues/368 --- fastapi_cachex/state/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastapi_cachex/state/manager.py b/fastapi_cachex/state/manager.py index 6b4b40a..f42f15b 100644 --- a/fastapi_cachex/state/manager.py +++ b/fastapi_cachex/state/manager.py @@ -124,7 +124,7 @@ def _decode_state(self, cached: CacheEntry) -> StateData: try: return StateData(**state_dict) - except ValueError as e: + except (ValueError, TypeError) as e: msg = f"Invalid state data structure: {e}" raise StateDataError(msg) from e