Repository navigation
Conversation
Store whether empty invoices (no lines or zero total) should be created in the invoicing app. The setting defaults to create and is exposed on the v3 billing profile API; an update that does not send it keeps the stored value. The invoicing apps do not act on the setting yet.
The empty invoice mode checks returned plain errors. They now return generic validation errors, like the other validators in the repository.
When the workflow uses the omit empty invoice mode and the invoicing app reports the invoice as empty, billing deletes the app's invoice instead of syncing or finalizing it, clears the invoice's invoicing reference and records the outcome as skipped with reason empty_invoice. Nothing is collected for such an invoice, so billing books authorization and settlement itself and the invoice ends up paid.
…s omitted Omitting an empty invoice deletes it in the invoicing app, but only the invoice's own reference was cleared. Lines, detailed lines and their discounts kept pointing at the deleted objects, removed lines included. The line upserts keep a stored reference when a line arrives without one, so the references are now cleared with a dedicated adapter update next to the in-memory clear.
An invoice that was omitted from Stripe gets a new Stripe invoice once an edit gives it something to bill, without stale line references, and is then issued like any other invoice.
Deleting a Stripe invoice that no longer exists failed, which left the OpenMeter invoice stuck: after a successful delete, a rolled back transaction restores the Stripe reference and every retry deletes again. A draft removed by hand in Stripe has the same effect. The Stripe client now treats a 404 on delete as success and logs a warning. Every other error still fails, in particular deleting a non-draft invoice. Open for discussion: the 404 is handled in the client, following DeleteWebhook. Handling it in the app layer instead would keep the client a thin wrapper and let the app decide. Also note that a 404 is returned as well when the API key belongs to another account or mode, which the client cannot tell apart.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
borosr
force-pushed
the
feat/skip-empty-invoices
branch
from
November 16, 2026 10:52
0fe1cd5 to
951b43a
Compare
borosr
force-pushed
the
feat/skip-empty-invoices
branch
3 times, most recently
from
November 17, 2026 11:17
382d90d to
ccd4bed
Compare
This branch has not been deployed
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.
This draft adds an intentionally failing regression test for the Stripe idempotency concern in #5534. It is stacked on
feat/skip-empty-invoicesand contains only the reproducer.Issue
With
empty_invoice_mode = omit, an editable draft can become billable, empty, and then billable again:in_Ausinginvoice-create-<OpenMeter invoice ID>.in_Aand clears its Stripe references.CreateInvoicereuses the original creation key. While Stripe retains that key, API v1 replays the original response referencing deleted invoicein_A.No such invoice; retries repeat the failure while the cached response remains.Expected: recreation creates a fresh Stripe invoice, while ordinary retries of the same creation continue to reuse their invoice.
Stripe documents that API v1 replays the saved response for a reused idempotency key.
Reproducer
TestRecreateOmittedDraftInvoicecalls the production Stripe client against a local HTTP fake that retains creation responses after deletion. It first verifies that an ordinary creation retry reuses the original invoice, then deletes and recreates the draft and expects a new billable line to succeed.This is a client-level reproduction of the HTTP sequence; it does not drive the billing state machine or call live Stripe. The existing lifecycle tests mock
CreateInvoiceabove this boundary and therefore miss the cached response.Validation
No such invoice: 'in_1'; the recreated ID is stillin_1.The test remains red to demonstrate the issue; this draft does not include a production fix.


Confidence Score: 5/5
No additional issues were found beyond the intentionally failing reproducer acknowledged by `turip`.Summary
Adds a local HTTP test for recreating an omitted Stripe draft.
Reviews (1) · Last reviewed commit: "test(stripe): reproduce omitted draft in..." · Reviewed by Greptile