Skip to content

Fix critical build-app and credit regressions#93

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0ed8
Draft

Fix critical build-app and credit regressions#93
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0ed8

Conversation

@cursor

@cursor cursor Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

  • /api/build-app swallowed AI generation and Git provider push failures, then still emitted a terminal done event. Users could receive incomplete repositories while the UI reported success.
  • GitHub repos created by Build This App were public by default.
  • Build/scaffold/legacy analysis credit charging was missing or trusted client-supplied userId, and shared credit deductions used a read-modify-write sequence that could overspend under concurrent requests.

Root cause

Recent build launcher and billing changes reintroduced warning-only failure handling, placeholder generated files, body-scoped billing IDs, and non-atomic credit balance updates.

Fix

  • Make Build This App failures terminal SSE error events with no done, throw on push failures, reject empty AI output, dedupe generated paths, create GitHub repos private, and charge/refund authenticated users around incomplete builds.
  • Charge scaffold and legacy analysis against getCurrentUser().id only.
  • Make credit grants, renewals, deductions, and refunds update balances and insert audit transactions via atomic SQL statements.

Validation

  • pnpm exec eslint app/api/build-app/route.ts app/api/generate-scaffold/route.ts app/api/analyses/[id]/analyze/route.ts lib/credits.ts
  • pnpm exec tsc --noEmit
  • Mocked /api/build-app route harness: verified success emits done, AI failure and push failure emit terminal error with no done, charged failures refund, insufficient credits stop before repo creation, duplicate README is pushed once, and GitHub repo payload is private.
  • Mocked credit deduction harness: verified first 500-credit deduction succeeds, second concurrent-style deduction fails at balance 0, and SQL uses a current_balance >= amount conditional update.
Open in Web View Automation 

Co-authored-by: Cole Collins <DealPatrol@users.noreply.github.com>
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
repo-app-architect Ready Ready Preview, Comment Jun 15, 2026 11:09am
repofuse Ready Ready Preview, Comment, Open in v0 Jun 15, 2026 11:09am
v0-repo-app-architect Ready Ready Preview, Comment, Open in v0 Jun 15, 2026 11:09am

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