Skip to content

fix(subscription): preserve legacy cadences during metadata resolution - #5267

Merged
GAlexIHU merged 1 commit into
mainfrom
codex/fix-legacy-cadence-feature-resolution
Oct 13, 2026
Merged

GAlexIHU merged 1 commit into
mainfrom
codex/fix-legacy-cadence-feature-resolution

Conversation

@GAlexIHU

@GAlexIHU GAlexIHU commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Existing subscriptions with item billing cadences under 24 hours fail view loading when feature metadata is resolved, preventing billing synchronization. Tax metadata resolution can also block cancellation by revalidating the same legacy cadence.

Permit only the legacy minimum-cadence error during feature and tax metadata resolution. Create/update validation remains strict, other validation errors still fail, and stored cadences are preserved.

Notes for reviewer

  • Regression coverage includes item and entitlement feature resolution, cancellation with tax metadata, mixed validation errors, and ID-based billing sync that generates hourly periods and converges on retry.
  • Confirmed the new regressions fail against the unmodified implementation.
  • Validation: subscription, subscription-service, and product-catalog package tests; focused billing-sync integration tests; scoped Go fast lint and formatting checks.

Summary by CodeRabbit

  • Bug Fixes
    • Existing subscriptions with legacy short billing cadences can now be viewed and synced without losing their item cadence or feature details.
    • Cancellation remains available for these subscriptions, while unrelated updates continue to require a valid cadence.
    • Other validation and resolution errors are still reported.

RetriggerConfidence Score: 5/5

This PR appears safe to merge; no actionable issues were found.

What we checked:

  • Other errors still stop reads: errorsx.IsOnly rejects the error tree if any error falls outside the allowed list.
  • New cadences remain checked: Both commands still call strict spec.Validate() before saving items. The metadata exception does not replace those checks.

Summary

This PR lets feature and tax metadata resolution preserve stored legacy billing cadences shorter than 24 hours.

  • Only ErrRateCardBillingCadenceTooShort is tolerated; other errors still fail.
  • Create and update checks remain strict.
  • Added tests cover feature resolution, cancellation, mixed errors, and hourly billing periods with stable IDs on retry.
  • No actionable issues found. Tests were inspected, not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Stored subscription] --> B[Resolve item feature]
  B --> C{Errors from ChangeMeta}
  C -->|None or only short cadence| D[Load subscription view]
  C -->|Any other error| E[Return error]
  D --> F[Billing sync]
  D --> G[Cancel subscription]
  G --> H[Resolve tax metadata]
  H --> I{Errors from ChangeMeta}
  I -->|None or only short cadence| J[Save cancellation]
  I -->|Any other error| E
  K[Create or update] --> L[Strict spec validation]
  L -->|Short cadence| E
Loading

Reviews (1) · Last reviewed commit: "fix(subscription): preserve legacy caden..." · Reviewed by Greptile

@GAlexIHU
GAlexIHU requested a review from a team as a code owner October 8, 2026 11:50
@GAlexIHU GAlexIHU added the release-note/bug-fix Release note: Bug Fixes label Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: openmeterio/openmeter/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 660219c8-d5dd-4482-9772-a8ee68fd37fa
📥 Commits

Reviewing files that changed from the base of the PR and between 8f83b15 and e645e8b.

📒 Files selected for processing (6)
  • openmeter/billing/worker/subscriptionsync/service/sync_test.go
  • openmeter/subscription/README.md
  • openmeter/subscription/service/service_test.go
  • openmeter/subscription/service/synchelpers.go
  • openmeter/subscription/subscriptionview.go
  • openmeter/subscription/subscriptionview_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Persisted subscriptions with legacy short item cadences can now load and resolve item features despite the cadence validation error. Tests cover preserved validation behavior, cancellation, and subscription billing sync.

Changes

Legacy item cadence handling

Layer / File(s) Summary
Resolve persisted legacy cadence items
openmeter/subscription/subscriptionview.go, openmeter/subscription/service/synchelpers.go, openmeter/subscription/service/service_test.go, openmeter/subscription/subscriptionview_test.go, openmeter/subscription/README.md
View and tax configuration resolution ignore ErrRateCardBillingCadenceTooShort while preserving other errors. Tests check feature resolution, cadence values, validation errors, and cancellation. The README documents the existing-subscription behavior.
Verify legacy cadence billing sync
openmeter/billing/worker/subscriptionsync/service/sync_test.go
A regression test checks 168 hourly gathering lines through the weekly horizon, the billable sync state and next-sync time, and stable line identities after a repeated sync.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: turip

Merge Risk: ⚪ Minimal · up to e645e

The reviewed change has no identified issue that needs resolution before merge.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preserving legacy subscription cadences during metadata resolution.
✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@GAlexIHU
GAlexIHU requested a review from turip October 8, 2026 13:53
@GAlexIHU
GAlexIHU enabled auto-merge (squash) October 8, 2026 13:54
@GAlexIHU
GAlexIHU disabled auto-merge October 13, 2026 13:40
@GAlexIHU
GAlexIHU merged commit 378af57 into main Oct 13, 2026
@GAlexIHU
GAlexIHU deleted the codex/fix-legacy-cadence-feature-resolution branch October 13, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants