From 11a8711589c0377546d63d3a741e9ff8354541ac Mon Sep 17 00:00:00 2001 From: malnasleh Date: Thu, 28 May 2026 18:55:44 -0700 Subject: [PATCH] catch JsonDecodeError and clear cached credentials to prompt for re-log in --- cirro/auth/device_code.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cirro/auth/device_code.py b/cirro/auth/device_code.py index 6d27b066..eafb3044 100644 --- a/cirro/auth/device_code.py +++ b/cirro/auth/device_code.py @@ -236,7 +236,13 @@ def _load_token_info(self) -> Optional[OAuthTokenResponse]: if not self._persistence or not self._token_path.exists(): return None - token_info = json.loads(self._persistence.load()) + try: + token_info = json.loads(self._persistence.load()) + except (json.JSONDecodeError, ValueError): + logger.debug('Saved token file is empty or invalid, clearing it') + self._clear_token_info() + return None + if 'access_token' not in token_info: return None