Skip to content

RIPEstat: add retry/resilience, stale-cache fallback and diagnostics (v0.4.2-alpha) - #28

Merged
DeepZone merged 1 commit into
mainfrom
codex/implement-retry-and-resilience-for-ripestat
May 20, 2026
Merged

RIPEstat: add retry/resilience, stale-cache fallback and diagnostics (v0.4.2-alpha)#28
DeepZone merged 1 commit into
mainfrom
codex/implement-retry-and-resilience-for-ripestat

Conversation

@DeepZone

Copy link
Copy Markdown
Owner

Motivation

  • Improve robustness when querying RIPEstat so temporary network/HTTP errors do not immediately fail checks.
  • Make retry behaviour configurable and expose retry/fallback information in Data Source Diagnostics so operators can see why data is stale.
  • Provide an optional stale-cache fallback to continue serving results when live queries fail while keeping demo mode single-attempt and preserving backward cache compatibility.

Description

  • Added new configuration settings in backend/app/config.py and .env.example: ripestat_timeout_seconds, ripestat_max_retries, ripestat_retry_backoff_seconds, and ripestat_use_stale_cache_on_error, with sensible defaults.
  • Extended make_source_diagnostic(...) in backend/app/core/source_diagnostics.py to include optional fields retry_count, attempts, fallback_used, fallback_reason, and stale_cache_used.
  • Reworked RipeStatClient.get_with_diagnostics(...) in backend/app/services/ripe_stat_client.py to implement timeout/retry/backoff logic using the new settings, retry only on timeout/502/503/504/transient network errors, classify HTTP 429 as RATE_LIMITED (capturing Retry-After when present), and optionally fall back to stale cache entries (keeping backward compatibility for older cache shapes).
  • Kept demo mode behavior unchanged (no retries, attempts=1, retry_count=0, fallback_used=false, freshness=LIVE).
  • Frontend changes: extended SourceDiagnostic type in frontend/src/types.ts and updated ReportView (frontend/src/components/ReportView.tsx) to display Attempts, Retries, Fallback and Stale Cache, plus a small warning UI when a fallback was used and a rate-limit hint when status is RATE_LIMITED.
  • Report templates updated (backend/app/templates/report.md.j2 and backend/app/templates/report.html.j2) to include the new diagnostics columns and a note when cached fallback data was used.
  • Documentation and metadata: added Retry and Resilience section to README.md, added v0.4.2-alpha entry to RELEASE_NOTES.md, and bumped versions to v0.4.2-alpha (UI) / 0.4.2 (packages/runtime).

Testing

  • Ran backend unit tests with cd backend && pytest -q, which passed (73 passed, warnings unrelated to this change).
  • Built the frontend with cd frontend && npm run build, which completed successfully and produced a production build.
  • Added/updated automated tests covering retry and fallback scenarios in backend/tests/test_ripe_stat_client.py (timeout->success, 503->success, 404 no-retry, 429 rate-limited with Retry-After, timeout + stale cache fallback, timeout without cache, and demo-mode behavior) and a test for the diagnostic shape in backend/tests/test_source_diagnostics.py, and adjusted smoke tests to assert the new attempts diagnostic field; all automated tests passed.

Codex Task

@DeepZone
DeepZone merged commit c82bd48 into main May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant