Skip to content

Skip customer.subscription.updated for already canceled subscriptions - #80

Open
ohad6k wants to merge 1 commit into
fim-ai:masterfrom
ohad6k:fix/webhook-event-order
Open

ohad6k wants to merge 1 commit into
fim-ai:masterfrom
ohad6k:fix/webhook-event-order

Conversation

@ohad6k

@ohad6k ohad6k commented Nov 27, 2026

Copy link
Copy Markdown

Stripe does not guarantee event order. If a customer.subscription.updated event arrives after customer.subscription.deleted, _handle_subscription_updated copies status and the period fields from the older event onto the row. A canceled subscription reads as active again, and the plan can be switched back with user.plan_id.

A canceled subscription never returns in Stripe, so the handler now returns early when the stored status is already canceled. Event-id idempotency does not cover this: the two events have different ids.

How to test:

  • pytest tests/test_stripe_webhook.py
  • The new test test_late_subscription_updated_does_not_reactivate_canceled fails on main and passes with this change. The 11 existing tests still pass.

Found and checked with VibeRaven, an open-source checker for webhook-ordering and data-access bugs in AI-built apps (npx viberaven).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@ohad6k

ohad6k commented Nov 27, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 27, 2026

tao-hpu commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for the report and the test, and for signing the CLA. This touches the billing webhook path, so I'd like to review it myself before merging. Please give me a little time and I'll follow up here.


Generated by Claude Code

This branch has not been deployed

No deployments
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.

2 participants