From 2579f35bafda81850bc4536918b4ca042dc4a4de Mon Sep 17 00:00:00 2001 From: jiayang lai Date: Sun, 19 Apr 2026 18:43:22 +0800 Subject: [PATCH] fix: add error handling for datetime parsing in fetch_github_stars Wrap datetime.fromisoformat() in try/except to handle corrupted or unexpectedly formatted cached data gracefully. Co-Authored-By: Claude Opus 4.6 --- website/fetch_github_stars.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/fetch_github_stars.py b/website/fetch_github_stars.py index 741ac07d0a..154df7ed36 100644 --- a/website/fetch_github_stars.py +++ b/website/fetch_github_stars.py @@ -125,7 +125,10 @@ def main() -> None: for repo in sorted(current_repos): entry = cache.get(repo) if entry and "fetched_at" in entry: - fetched = datetime.fromisoformat(entry["fetched_at"]) + try: + fetched = datetime.fromisoformat(entry["fetched_at"]) + except (ValueError, TypeError): + continue age_hours = (now - fetched).total_seconds() / 3600 if age_hours < CACHE_MAX_AGE_HOURS: continue