Skip to content

fix(billing): withhold the free allowance from Gmail aliases of an existing account - #9418

Merged
waleedlatif1 merged 4 commits into
stagingfrom
fix/gmail-alias-free-credit
Oct 28, 2026
Merged

waleedlatif1 merged 4 commits into
stagingfrom
fix/gmail-alias-free-credit

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Gmail delivers every dot and +tag variant of an address (and its googlemail.com twin) to one inbox, so a single person could register a.b@gmail.com, ab+1@gmail.com, … and get a fresh free allowance on each
  • A new account whose Gmail inbox another account (banned or not) already holds is now created with no free allowance — same "one free trial per identity" treatment returning deleted-account identities already get; signup itself is never refused, and paid plans and prepaid credit are untouched
  • Applied on both allowance paths: handleNewUser and the createUserStatsIfMissing fallback, via one identityHadFreeAllowance check
  • New gmailMailbox() SQL expression in the schema (built on foldedEmail) plus partial index user_gmail_mailbox_idx, so the lookup is an index probe instead of a scan of user; migration builds it CONCURRENTLY
  • Non-Gmail domains are never folded; fails open (logs, grants the allowance) on lookup error

Type of Change

  • Bug fix

Testing

  • lib/users/gmail-alias.integration.ts against real Postgres with INTEGRATION_DB_PROVISION=migrate (exercises migration 0439): 5/5 pass. Disabling the check turns the 3 withholding tests red; one test asserts the plan uses user_gmail_mailbox_idx
  • lib/billing/core/usage.test.ts: 25/25 pass
  • check:migrations, check:file-names, check:test-patterns, check:comment-hygiene, biome on touched files; drizzle-kit generate reports no drift
  • Full type-check / audits / suite left to CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 28, 2026 7:58pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the stated allowance trade-off.

Summary

This PR limits the free allowance to the first account on a Gmail inbox.

  • Later accounts using an existing Gmail inbox start without the free allowance.

Reviews (4) · Last reviewed commit: "fix(billing): count any earlier account ..." · Reviewed by Greptile

Comment thread apps/sim/lib/users/gmail-alias.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/users/gmail-alias.ts
Comment thread apps/sim/lib/users/gmail-alias.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/users/gmail-alias.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/users/gmail-alias.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit fb74b4b into staging Oct 28, 2026
57 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/gmail-alias-free-credit branch October 28, 2026 20:06

This branch was previously deployed

1 inactive deployment
Preview — 6c64da67 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant