Repository navigation
subscription.cancelled sync fails: duplicate unique id across persisted lines and charges with enable_credit_then_invoice: true #4413
pratham-ez
started this conversation in
General
Replies: 1 comment
|
Hey @pratham-ez Sorry for not picking this up earlier. We are not doing a great job of documenting feature readiness in OpenMeter GH so its on us, but that feature was mid-development and unstable (far before pre-release). It has since been completed & should be working correctly now. Until we start doing a better job of documenting these here I suppose the rule of thumb would be to follow the Kong Konnect announcements for feature readiness: features marked as public beta or GA there are expected to work here as well (when the feature is present in OpenMeter) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Title
subscription.cancelledsync fails withduplicate unique id across persisted lines and chargeswhencredits.enable_credit_then_invoice: trueEnvironment
10f948f17(staging billing-worker image)credits.enabled: truecredits.enable_credit_then_invoice: trueevents.enabled: truecredit_then_invoice(usage-based rate cards only — standard + premium features)send_invoice), collection intervalPT5MSummary
With
enable_credit_then_invoice: true, the first subscription sync succeeds (charges + gathering mirror lines are created). Any subsequent sync (cancel, cron resync, plan change) fails inpersistedstate.Loader.LoadForSubscriptionbecause the sameunique_reference_idexists in bothbilling_invoice_lines(charge-backed gathering mirror) andcharges.The cancel event retries 9 times and lands in DLQ. The gathering invoice is never trimmed to
activeTo, and no standard invoice is cut from the native cancel path.Reproduction
credits.enabled: trueandcredits.enable_credit_then_invoice: true.subjectKeys= org UUID.credit_then_invoiceplan with two usage-based rate cards (e.g.synqed_feature_standard@ $2/unit,synqed_feature_premium@ $1/unit).POST /api/v1/events(CloudEvents withTOOL_CALL_STANDARD/TOOL_CALL_PREMIUM).Observed error
synchronize subscription: duplicate unique id across persisted lines and charges:
01KSA6NP21H4EYBP2KB4QNZKC6/default/synqed_feature_premium/v[0]/period[0]
Full log context:
{
"ts": "2026-05-23T10:46:11Z",
"level": "WARN",
"caller": "openmeter/watermill/router/logger.go:40",
"msg": "Error occurred, retrying",
"service.name": "openmeter-billing-worker",
"service.version": "10f948f17",
"retry_no": 6,
"max_retries": 9,
"error.message": "synchronize subscription: duplicate unique id across persisted lines and charges: 01KSA6NP21H4EYBP2KB4QNZKC6/default/synqed_feature_premium/v[0]/period[0]"
}
After 9 retries →
Failed to process message, message is going to DLQon topicio.openmeter.subscription.v1.subscription.cancelled.Concrete example (staging)
What we are NOT doing
ForceInvoiceCustomerwithprogressiveBillingOverride: true)POST /api/v1/billing/invoices/invoiceor/advanceThis reproduces on stock OpenMeter with the documented
credit_then_invoiceconfig.Impact
enable_credit_then_invoice: truebreaks on the second billing-worker sync (cancel, renewal, cron subscription-sync, plan edit).subscription.cancelledevents.POST /api/v1/subscriptions/{subscriptionId}/cancel
{"timing": "immediate"}
All reactions