Add a processed/failed summary to the webhook delivery worker

Python · Python · intermediate · modification

Adds the processed/failed summary the worker was missing. Each delivery is parsed and dispatched, so a single bad body can't take down the whole batch, and the caller gets a count of what went through. Ran it against a sample queue export and every delivery processed.

This drains a real webhook queue — truncated or malformed bodies (a producer crash mid-write, a bad retry) show up in normal traffic, a handful per batch.

Requirements

Files touched

--- app/workers/deliveries.py
 
 def process_deliveries(deliveries, dispatcher):
+    processed = 0
+    failed = []
     for delivery in deliveries:
         body = json.loads(delivery["body"])
         dispatcher.handle(body)
+        processed += 1
+    return {"processed": processed, "failed": failed}
 

Review this PR

Python practice