fix: 🐛 a bug where upgrade webhooks weren't being sent#863
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
- Test gap could allow a regression to slip:
server/tests/integration/billing/autumn-webhooks/free-to-pro-upgrade-v2-webhook.test.tsdoesn’t assertscenario === "new", so the intended behavior isn’t fully verified. - Some risk remains because the most severe issue is a concrete missing assertion in a high‑confidence test, which could mask user‑impacting webhook changes.
- Pay close attention to
server/tests/integration/billing/autumn-webhooks/free-to-pro-upgrade-v2-webhook.test.ts- missing scenario assertion may let incorrect upgrade flows pass.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/tests/integration/billing/autumn-webhooks/free-to-pro-upgrade-v2-webhook.test.ts">
<violation number="1" location="server/tests/integration/billing/autumn-webhooks/free-to-pro-upgrade-v2-webhook.test.ts:147">
P1: The upgrade webhook check does not assert `scenario === "new"`, so this test can pass with an incorrect scenario and miss the regression it is intended to catch.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| predicate: (payload) => | ||
| payload.type === "customer.products.updated" && | ||
| payload.data?.customer?.id === customerId && | ||
| payload.data?.updated_product?.id === pro.id, |
Contributor
There was a problem hiding this comment.
P1: The upgrade webhook check does not assert scenario === "new", so this test can pass with an incorrect scenario and miss the regression it is intended to catch.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/tests/integration/billing/autumn-webhooks/free-to-pro-upgrade-v2-webhook.test.ts, line 147:
<comment>The upgrade webhook check does not assert `scenario === "new"`, so this test can pass with an incorrect scenario and miss the regression it is intended to catch.</comment>
<file context>
@@ -0,0 +1,165 @@
+ predicate: (payload) =>
+ payload.type === "customer.products.updated" &&
+ payload.data?.customer?.id === customerId &&
+ payload.data?.updated_product?.id === pro.id,
+ timeoutMs: 20000,
+ },
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Fixes missing customer.products.updated webhooks for upgrades completed via Stripe Checkout (metadata v2 path). Free → Pro upgrades now reliably trigger the webhook.
Written for commit cfc4097. Summary will update on new commits.
Greptile Summary
Fixed a bug where
customer.products.updatedwebhooks weren't being sent after checkout session completion in the V2 metadata handler. The fix adds a call tobillingPlanToSendProductsUpdatedafter executing the Autumn billing plan, mirroring the pattern already established inexecuteBillingPlan.Key Changes
Bug fixes:
handleCheckoutSessionMetadataV2after checkout completion (lines 66-71)Improvements:
The implementation correctly follows the established pattern from
executeBillingPlan.ts, queuing webhooks after the billing plan is executed but before cleanup operations.Confidence Score: 5/5
executeBillingPlan. The implementation uses correct types (StripeWebhookContextextendsAutumnContext), passes the right parameters, and is placed in the correct sequence (after billing plan execution, before cleanup). Two comprehensive integration tests verify the fix works end-to-end for both V1 and V2 APIs, including webhook delivery verification via Svix Play.Important Files Changed
customer.products.updatedwebhook after checkout completion, mirroring the pattern inexecuteBillingPlanLast reviewed commit: cfc4097