diff --git a/src/alpine_bits_python/api.py b/src/alpine_bits_python/api.py index 27ef88a..db4b521 100644 --- a/src/alpine_bits_python/api.py +++ b/src/alpine_bits_python/api.py @@ -923,6 +923,10 @@ async def handle_webhook_unified( ) # 8. Update status and link created entities when available + # Re-add to session in case processor called rollback (e.g., for duplicates) + if webhook_request not in db_session: + webhook_request = await db_session.merge(webhook_request) + webhook_request.status = WebhookStatus.COMPLETED webhook_request.processing_completed_at = datetime.now(UTC)