chore(server): remove the billing plans boot loader flow - #1870
chore(server): remove the billing plans boot loader flow#1870rohilsurana wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesThe PR removes YAML/blob-based billing plan loading from startup. Testbench initialization gains pre-start database seeders, and billing E2E tests create required products and plans through database and admin APIs. Billing plan loading removal
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
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. Comment |
Coverage Report for CI Build 31480556679Coverage increased (+0.07%) to 48.17%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 30aa3df8-3256-4193-b63e-a3f29da80747
📒 Files selected for processing (9)
billing/config.gocmd/serve.goconfig/sample.config.yamlcore/event/service_test.gointernal/bootstrap/service.gointernal/store/blob/plan_repository.gotest/e2e/regression/billing_test.gotest/e2e/regression/testdata/plans/subscription.credits.yamltest/e2e/testbench/testbench.go
💤 Files with no reviewable changes (5)
- config/sample.config.yaml
- test/e2e/regression/testdata/plans/subscription.credits.yaml
- internal/store/blob/plan_repository.go
- internal/bootstrap/service.go
- core/event/service_test.go
rohilsurana
left a comment
There was a problem hiding this comment.
Automated code review (xhigh). Findings below, most important first. The first two look like real boot/runtime regressions worth confirming before merge.
| logger.Info("migrated billing plans") | ||
| } | ||
|
|
||
| // apply roles over nil org id |
There was a problem hiding this comment.
Likely hard boot failure when credit_overdraft_product is set.
Removing the boot plan loader drops the only thing that seeded credit_overdraft_product before InvoiceService.Init. On a fresh database with billing.customer.credit_overdraft_product set, Init calls productService.GetByID(...), gets not-found, and returns failed to get credit overdraft product, so StartServer fails and the server never comes up. The e2e suite hides this with a new pre-start DB seeder, but production has no equivalent replacement.
There was a problem hiding this comment.
Covered for our rollout: prod and staging set credit_overdraft_product by UUID, the product already exists in the DB and is in the reconcile billing-products export (behavior: credits), so Init resolves it at boot. Fresh installs must seed the catalog via reconcile first, which is now noted in the PR description. Leaving Init fail-fast rather than changing that core behavior in this PR.
| StripeKey string `yaml:"stripe_key" mapstructure:"stripe_key"` | ||
| StripeAutoTax bool `yaml:"stripe_auto_tax" mapstructure:"stripe_auto_tax"` | ||
| StripeWebhookSecrets []string `yaml:"stripe_webhook_secrets" mapstructure:"stripe_webhook_secrets"` | ||
| DefaultCurrency string `yaml:"default_currency" mapstructure:"default_currency"` |
There was a problem hiding this comment.
Plan/product seeding is removed with no replacement, and plans_path is now silently ignored.
For a deployment that defined its catalog via plans_path and set default_plan, the key is now an unknown field that config loading ignores. Nothing seeds the plans on boot, so EnsureDefaultPlan fails for every new org (only logged in listener.go, so the org comes up with no subscription or entitlements), and CreateCheckout fails plan-not-found for those plan names. Please confirm the reconcile/admin path fully covers this before merge.
There was a problem hiding this comment.
Covered: pixxel sets no default_plan, and plans are owned by reconcile now. Removed the stale plans_path docs. plans_path being ignored is the intended removal; fresh-install ordering is noted in the PR description.
What
Removes the
billing.plans_pathboot loader end to end. Billing products, plans, prices, and features are managed through the reconcile flow now (theBillingProductandBillingPlankinds), so the server no longer reads a plans file at startup.cmd/serve.go: drop the billing blob store and theMigrateBillingPlanscall.internal/bootstrap: drop theBillingPlanRepositoryandPlanServicedependencies and theMigrateBillingPlansmethod.billing/config.go: remove theplans_pathfield.internal/store/blob/plan_repository.go: removed, no longer used.config/sample.config.yaml: drop the sample entry.test/e2e: the billing regression suite seeds the fixtures it needs (support_creditsandenterprise_yearly) through the admin API inSetupSuiteinstead of the boot loader.UpsertPlansandplan.Filestay: the adminCreatePlanhandler still uses them to create a plan with its products.Why it is safe
Existing plans and products live in the database, so this is a no-op for a server that has already migrated. The reconcile flow (
frontier reconcilewith theBillingProduct/BillingPlankinds) owns this state now.Gating
This is the billing counterpart to #1767 (the resources_config boot loader removal). Same rule: a deployment must run the reconcile flow so plans and products are owned there, and drop
plans_pathfrom its own config, before taking this build.One boot-time dependency to call out: if a deployment sets
billing.customer.credit_overdraft_product(orbilling.customer.default_plan), that product or plan must already exist in the database before the server starts.InvoiceService.Initresolves the overdraft product at boot and fails startup if it is missing, andEnsureDefaultPlanneeds the default plan to exist. The boot loader used to seed these; now they must come from the reconcile flow or already be present. Deployments that already ran the loader in a past release have this data, so this is a no-op for them. A fresh install must seed the catalog through reconcile first.Verification
go build ./...,go vet ./..., and unit tests forinternal/bootstrap,billing/plan,core/event, andinternal/api/v1beta1connectpass. gofmt and lint clean.