Repository navigation
fix(billing): map invoice subscription ids onto the documented fields - #5464
tothandras merged 2 commits into
Conversation
mapSubscriptionReferencesToAPI wrote the subscription id into item.id and the item id into subscription.id. Invoice responses therefore swapped the two identifiers described by InvoiceLineSubscriptionReference. Fixes openmeterio#5454
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
tothandras
left a comment
There was a problem hiding this comment.
Thanks for the contribution, and for the clear write-up and regression test!
The fix looks right. The subscription and item IDs are stored correctly everywhere they're written; only this v1 mapper had them swapped. I checked that the new test fails against the old mapper and passes with the fix.
Before we can merge, please sign the Contributor License Agreement. The license/cla check is still pending.
Two small requests inline:
- mention in the PR description that
invoice.*webhook payloads change too, not only the API response - move the test to
invoiceline_test.go
The failing OpenAPI codegen and release note label checks aren't caused by this change, so there's nothing to do there.
| out := &api.InvoiceLineSubscriptionReference{ | ||
| Item: api.IDResource{ | ||
| Id: optSub.SubscriptionID, | ||
| Id: optSub.ItemID, |
There was a problem hiding this comment.
This mapper also builds the payload for invoice.* webhooks (through MapEventInvoiceToAPI in the notification consumer), so the fix changes webhook payloads as well as API responses. Payloads are stored when the event is created, and resends replay the stored copy. Events from before this change will keep the swapped IDs under the same payload version.
Could you add a short note to the PR description saying that both the invoice API response and invoice.* webhook payloads change, and that anyone who worked around the swap should remove the workaround? We'll decide on our side whether it also needs the breaking-change label.
|
Added the note about API responses and This comment was drafted with Claude Code. |
|
Thank you, @pcbeingused333, for your contribution! |
Fixes #5454
Overview
mapSubscriptionReferencesToAPIcopiedSubscriptionIDintosubscription.item.idandItemIDintosubscription.subscription.id. The domain model and the OpenAPI spec keep those ids apart (subscriptionis the subscription,itemis the subscription item), and the v3 converter (billingcommon/convert.go) already writes them that way. Standard invoice lines and gathering invoice lines both use this mapper, so both responses had the two ids swapped.The fix writes
ItemIDtoitem.idandSubscriptionIDtosubscription.id. The phase id and billing period are unchanged.Behaviour change
Both the invoice API response and
invoice.*webhook payloads change:subscription.subscription.idandsubscription.item.idnow carry the right ids. Anyone who worked around the swap should remove the workaround. Webhook events created before this change keep the swapped ids in their stored payloads.Notes for reviewer
TestMapSubscriptionReferencesToAPIKeepsIdsOnDocumentedFieldschecks the three ids, the billing period, and that a nil reference stays nil. It fails on the swapped subscription id before the change and passes after:This change was prepared with the help of an AI coding assistant and submitted by the account owner.


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Corrects the subscription and item IDs returned on invoice lines.
Reviews (2) · Last reviewed commit: "test(billing): move subscription referen..." · Reviewed by Greptile
Summary by CodeRabbit