Bug: _load_last_report_cache silently swallows all exceptions, masks cache corruption
Author: 23241a6749Created Jul 9, 2026Updated Sep 13, 2026
Summary
_load_last_report_cache() at last30days.py:761 catches all Exception and silently returns None (cache miss). If the cache file at ~/.config/last30days/last-report.json is corrupted, truncated, version-mismatched, or contains unexpected data, the error is swallowed with zero diagnostic output. The report is silently regenerated — users lose the performance benefit of caching with no indication of why.
Impact
Low-to-medium. Not a crash — graceful degradation to cache miss. But users who notice reports always regenerating have no way to diagnose why. In a cron/automation context, this means wasted token spend on every run.
Root cause
try:
payload = json.loads(cache_path.read_text(encoding="utf-8"))
if payload.get("schema") != REPORT_CACHE_VERSION:
return None
...
return ...
except Exception:
return None # <-- silently discards all errors
Suggested fix
Log the exception to stderr before returning None:
except Exception as exc:
sys.stderr.write(f"[last30days] Cache read failed, regenerating: {exc}\n")
return None
Severity
Medium — silent data loss (cache), no crash.
Source: mvanhorn/last30days-skill