From 93c284a67d67c7a70ccc400b804543c2202c7045 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 11 Mar 2025 08:33:18 -0700 Subject: [PATCH] fix: Handle JSONDecodeError when loading model cache file --- aider/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aider/models.py b/aider/models.py index 3c85b73e5..7eb022681 100644 --- a/aider/models.py +++ b/aider/models.py @@ -153,7 +153,11 @@ class ModelInfoManager: if self.cache_file.exists(): cache_age = time.time() - self.cache_file.stat().st_mtime if cache_age < self.CACHE_TTL: - self.content = json.loads(self.cache_file.read_text()) + try: + self.content = json.loads(self.cache_file.read_text()) + except json.JSONDecodeError: + # If the cache file is corrupted, treat it as missing + self.content = None except OSError: pass