fix(api): revert deterministic retry billing id (free-scan on redelivery)#3401
Merged
Conversation
…redelivery) The deterministic pending:retry:<parent> reservation id introduced a worse, realistic bug: billing consume is idempotent on the id AND a refund leaves the consume event in place, so a failed-create-then-refund followed by the standard webhook redelivery would reuse the key, skip the debit, and run the scan for free. Revert to a unique random reservation id so redelivery re-debits correctly. Concurrent duplicate SCANS are still deduped by the Maced idempotency key; the residual concurrent-only over-charge requires concurrent duplicate webhook delivery (unverified) and is not worth the regression risk of a shared reservation.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Contributor
|
🎉 This PR is included in version 3.101.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Follow-up to #3400. The deterministic
pending:retry:<parent>billing reservation id it introduced has a realistic bug, so this reverts it to a unique random id.The bug
Billing consumption is idempotent on
sourceResourceId, and a refund creates a separaterefundevent while leaving the originalconsumeevent in place (billing-included-usage-refunds.ts). With a deterministic per-parent reservation id:pending:retry:<parent>.consumeidempotency key remains).This is the normal sequential retry-on-failure path, so it's realistic — a worse trade than the (unverified, concurrent-only) over-charge the deterministic id was meant to prevent.
Fix
Revert to a unique random reservation id per create call, so a redelivered retry re-debits correctly. Concurrent duplicate scans are still deduped by the Maced idempotency key (unchanged); the residual concurrent-only reservation over-charge requires Maced to deliver duplicate webhooks concurrently (unverified) and isn't worth reintroducing a realistic free-scan to close.
Testing
npx jest src/security-penetration-tests→ 154 green, typecheck + prettier clean.Summary by cubic
Reverts the retry billing reservation id to a unique random id to prevent free scans on webhook redelivery after a refunded failure. Concurrent duplicate scans are still deduped by the Maced idempotency key, and billing now re-debits on redelivery.
pending:<uuid>sourceResourceId; removepending:retry:<parent>.Written for commit ba6886c. Summary will update on new commits.