fix(backend): gate hosted users without a stripe subscription - #2780
Merged
Conversation
Treat missing billing, none, and local trialing rows as awaiting_checkout so existing accounts see the Start-trial gate until Checkout succeeds. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
A customer-only billing document used to fail Zod parse on /billing/status and fail-open the client gate. Derive missing status as awaiting_checkout and stamp it when creating the Stripe customer. Co-authored-by: Tyler Dane <tyler-dane@users.noreply.github.com>
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.
Summary
Google OAuth for an email that already has a Compass user is a SIGNIN (session remapped; existing calendars stay). The Start-trial gate never appeared because missing billing,
none, and local/backfilltrialingrows were writable.Hosted users without a Stripe subscription id now derive as
awaiting_checkout(read-only). A trial starts only via Stripe Checkout. Self-host is unchanged (billing.isConfigured: falsekeeps the app open).backfill-billingstampsawaiting_checkoutinstead of a local 7-day trial.Follow-up: creating a Stripe customer no longer leaves a billing document without
subscriptionStatus(that used to fail Zod parse and fail-open the client gate).Simplicity
Derivation-only for existing unpaid rows; no Mongo migration. Customer create stamps
awaiting_checkoutonly when status is missing ornone.Automated validation
bun test:backend: 345 pass, 1 skip (first commit)bun test:scripts: 33 passbun type-check: passbun lint: pass (pre-existing warnings only)Staging Google OAuth cannot be finished from this agent. After deploy, the same sign-in should keep calendars and show Start your 7-day trial.
Independent review
Approve after fixing P1: a customer-only billing document must not drop the client gate. No remaining P0/P1.
Test plan
bun test:backendbun test:scriptsbun type-checkbun lintbun packages/scripts/src/testing/test-mongo-env.ts backend --on the four billing files after the P1 fix