Skip to content

Fix QStash webhook delivery state handling - #26

Merged
suguanYang merged 1 commit into
stagingfrom
fix/wangbinqi/qstash-webhook-state
May 12, 2026
Merged

suguanYang merged 1 commit into
stagingfrom
fix/wangbinqi/qstash-webhook-state

Conversation

@suguanYang

Copy link
Copy Markdown
Contributor

Summary

Fixes QStash webhook delivery state handling for retry callbacks and lost terminal callbacks.

  • Keep normal QStash callbacks in delivering when the destination response is non-2xx, and only mark them delivered on 2xx responses.
  • Preserve terminal webhook event state when an older retry callback arrives late.
  • Publish QStash messages with a deterministic deduplication id and label.
  • Reconcile stale delivering events from QStash terminal delivery logs during the existing webhook recovery task.
  • Add a QStash base URL override for local development and end-to-end verification.

Fixes #24.

Verification

  • uv run --group lint ruff check apps/api/app/api/v1/routes/qstash_callbacks.py apps/api/tests/contract/test_qstash_callback_contract.py apps/worker/app/core/tasks/webhook_tasks.py apps/worker/tests/contract/test_webhook_recovery_contract.py packages/shared-python/shared/services/webhook/qstash_publisher.py packages/shared-python/shared/core/config/qstash.py
  • uv run --package knowhere-api-app --group dev pytest apps/api/tests/contract/test_qstash_callback_contract.py -q
  • uv run --package knowhere-worker-app --group dev pytest apps/worker/tests/contract/test_webhook_recovery_contract.py -q
  • Local webhook delivery e2e using the repo local Postgres/Redis stack, the running API QStash callback route, a local QStash-compatible HTTP service, and a local customer webhook returning 503 then 204. Verified callback log statuses [503, 204], final event status delivered, and stale-delivering reconciliation result {"status":"success","recovered":0,"provider":"qstash","reconciled":1}.

@suguanYang
suguanYang merged commit ea73c72 into staging May 12, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant