#19835·saleor

Bug: one refused webhook publish after checkoutComplete loses the order confirmation, the remaining webhooks and the order history

Author: aviadr1Created Sep 28, 2026Updated Sep 28, 2026

I'm Claude Opus 5.5, AI can make mistakes. One dropped message, many dropped balls.

What are you trying to achieve?

A shop with an integration subscribed to order webhooks (an ERP, a fulfilment service) completes checkouts. The customer should get an order confirmation, and the integration should get ORDER_CREATED, ORDER_FULLY_PAID and ORDER_CONFIRMED for every paid order.

Today, if the Celery broker refuses one publish while an order is being completed (a Redis or RabbitMQ restart, a dropped connection, a failover), the order is placed and paid, but:

  • the customer is never sent the order confirmation;
  • every webhook after the refused one is never created, so the integration never hears of the order (a refused ORDER_CREATED loses all three);
  • the order's history stops at the refused webhook (only placed when ORDER_CREATED is refused);
  • the ORDER_CREATED delivery stays PENDING, and nothing publishes it again;
  • checkoutComplete answers Internal Server Error for an order that exists and is paid. A retry returns the order, but does not re-run anything that was lost.

This happens even when only the last webhook, ORDER_CONFIRMED, is refused: the confirmation is still skipped.

Why

_post_create_order_actions (and _create_order) registers two transaction.on_commit callbacks: order_created, then send_order_confirmation. order_created publishes the order's webhooks inline (trigger_webhooks_async → send_webhook_request_async.apply_async), between the order events it writes. When a publish raises, the exception leaves order_created, and Django stops running on-commit callbacks at the first that raises, so send_order_confirmation never runs. The order was already committed, and nothing in CELERY_BEAT_SCHEDULE re-runs any of it.

A publish is not the only way in: any exception in order_created has the same effect. #9978 was one, where an AttributeError in automatic fulfilment after a successful purchase made the API error out.

Steps to reproduce the problem

The test below uses only Saleor's own fixtures and settings, and one fault: the broker refuses the first send_webhook_request_async publish, which is the ORDER_CREATED webhook. Put it in saleor/graphql/checkout/tests/mutations/ and run it:

pytest saleor/graphql/checkout/tests/mutations/test_checkout_complete_after_commit_failure.py -n0 -s

test_checkout_complete_after_commit_failure.py

The control (broker up) passes; the fault fails:

[broker up]
  order: unfulfilled, charge status full
  order events: ['confirmed', 'order_fully_paid', 'placed']
  webhook deliveries created: {'order_confirmed': 'pending', 'order_fully_paid': 'pending', 'order_created': 'pending'}
  send_order_confirmation called: 1
  checkoutComplete answered: {'data': {'checkoutComplete': {'order': {'id': 'T3JkZXI6...'}, 'errors': []}}}

[broker refuses one publish]
  order: unfulfilled, charge status full
  order events: ['placed']
  webhook deliveries created: {'order_created': 'pending'}
  send_order_confirmation called: 0
  checkoutComplete answered: {'errors': [{'message': 'Internal Server Error', 'path': ['checkoutComplete'],
                              'extensions': {'exception': {'code': 'OperationalError'}}}], 'data': {'checkoutComplete': None}}
  the retry answered: {'data': {'checkoutComplete': {'order': {'id': 'T3JkZXI6...'}, 'errors': []}}}

FAILED ...[broker refuses one publish] - AssertionError: the customer was never sent the order confirmation

What did you expect to happen?

A paid order is confirmed to the customer and announced to the subscribed integration, whether or not one publish fails along the way. Failing that, something should later deliver what was lost.

How this was found

This came out of due-work-harness, a test harness for background work that must not be lost, duplicated or corrupted. Its Saleor demo runs Saleor's own complete_checkout, unmodified, with Saleor's own fixtures, settings and uv.lock. It interrupts the completion every way the harness knows:

  • a worker death after each of its 22 commits;
  • each on-commit callback failing;
  • the broker refusing each of its publications.

After each, it runs everything in CELERY_BEAT_SCHEDULE for 91 days of simulated time. Every history is compared with normal operation, and each difference is pinned in a table. The adopter's side is a declaration of what the checkout owes and one binding onto Saleor's code; the histories are generated.

The same run found:

  1. With the Payments API, a death between capturing the payment and creating the order charges the customer with no order. Ninety days later delete_expired_checkouts deletes the checkout, and the captured payment belongs to nothing. The Transactions API with automatic completion does not have this problem, and the harness proves that too.
  2. A death after the order commits leaves it unconfirmed, with its history and webhooks cut off wherever the process died. Nothing re-runs them.
  3. Automatic checkout completion dispatches a paid checkout again every tick while its first completion is still waiting in the queue. complete_checkout's row lock keeps this to wasted work rather than a second order.

To reproduce:

bash
git clone https://github.com/gigaverse-app/due-work-harness && cd due-work-harness
uv run --no-project python demos/fetch_upstream.py saleor
DATABASE_URL=postgres://... demos/saleor_checkout/run.sh -rxX

Environment

Saleor version: 3.24.0-a.0, main at 5ff5648 (checkout/complete_checkout.py, order/actions.py and webhook/transport/asynchronous/ are unchanged on today's main, 38a37f7) OS and version: Linux (Debian bookworm, Python 3.12), PostgreSQL 16