feat(engine): add webhook exponential backoff retry worker and dead-letter status tracking

Aperta
#13 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
fastapi, python
Ambito
api, backend, testing

Direzione di ricerca

Start by reading engine/app/webhooks.py and engine/app/models.py, then inspect the replay endpoint in engine/app/main.py and the existing tests in engine/tests/test_webhooks.py. The issue calls for a bounded retry worker, retry metadata, a migration at engine/alembic/versions/0004_webhook_retry_dead_letter.py, and mocked failure tests. Done means retries are scheduled, exhausted deliveries become dead letters, the admin endpoint exposes retry metadata, and replay resets state and dispatches immediately.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

complexity: medium engine

Context

engine/app/webhooks.py dispatches HMAC-SHA256 signed events once synchronously on SEP-24 state transitions and records delivered or failed in WebhookDelivery. Production wallet receivers experience transient downtime, so adding bounded exponential backoff retries and dead-letter status tracking lets integrators test realistic webhook recovery behavior.

Target Files

  • Modify engine/app/webhooks.py (_send_signed_webhook, dispatch_transaction_webhook, replay endpoint)
  • Modify engine/app/models.py (WebhookDelivery)
  • Modify engine/app/main.py
  • Create engine/alembic/versions/0004_webhook_retry_dead_letter.py
  • Modify engine/tests/test_webhooks.py

Acceptance Criteria

  • Add next_retry_at and last_error columns (and support retrying / dead_letter statuses) on WebhookDelivery with an Alembic migration (0004_webhook_retry_dead_letter.py).
  • Implement an async background retry loop (or FastAPI lifespan worker) using bounded exponential backoff (e.g. up to 5 attempts) when _send_signed_webhook encounters non-2xx responses or network errors.
  • Transition deliveries that exhaust max retry attempts to dead_letter status and expose retry metadata in GET /admin/webhooks/deliveries.
  • Ensure manual POST /admin/webhooks/deliveries/{delivery_id}/replay resets retry state and dispatches immediately.
  • Add pytest tests in engine/tests/test_webhooks.py mocking httpx failures to verify backoff scheduling and dead_letter transition.
Lingua principale
Python
Stelle
0
Fork
1
Merge medio
19h 43m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sepbox-dev/sepbox

Tutte le issue di sepbox-dev/sepbox

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.