Skip to content

fix(billing): fail closed on legacy Chat payer reads and cover the Chat plan gate - #9553

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-gate-release-review
Nov 1, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/chat-gate-release-review

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Copilot key validation: the legacy-account branch now reads the payer's subscription with onError: 'throw', matching the direct-account branch. A transient DB error used to read as "no subscription", so the Chat plan check could refuse a paying payer with a 402; it now fails closed with a retryable 500
  • Adds chat-access.integration.ts: the Chat plan verdict against real Postgres balances — a free org payer and a free personal payer are refused until they hold prepaid credits, and a paid payer is admitted with no balance
  • Adds a run admission case: a payer whose plan excludes Chat gets the upgrade card before the usage check and before any worker dispatch

Type of Change

  • Bug fix

Testing

  • run.test.ts and validate/route.test.ts pass in full (198 tests)
  • chat-access.integration.ts passes against Postgres via bun run test:integration (3 tests)
  • Red proofs: removing the admission gate fails the new run case; balance > 0 → >= 0 fails both free-payer integration cases; deleting the paid-plan early return fails the paid-payer case
  • Lint, type-check, and audits run in 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 Nov 1, 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 Nov 1, 2026 8:26pm 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 3 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

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge, with no outstanding actionable findings.

Summary

Legacy-account subscription reads now use onError: 'throw', so a failed read returns 500 instead of treating the payer as free.

  • Legacy Copilot key validation stops when it cannot read a subscription.
  • Chat access tests cover free and paid payer balances.
  • Run tests check Chat plan refusals before worker dispatch.

Reviews (3) · Last reviewed commit: "test(billing): pass the route context in..." · Reviewed by Greptile

@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 Nov 1, 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 4 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

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 Nov 1, 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 4 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 f8a561d into staging Nov 1, 2026
58 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/chat-gate-release-review branch November 1, 2026 20:36

This branch was previously deployed

1 inactive deployment
Preview — 42f5eabe Deployed Nov 1, 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