Skip to content

Fix critical build and credit accounting failures#92

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

Fix critical build and credit accounting failures#92
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-1534

Conversation

@cursor

@cursor cursor Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Stop Build This App from reporting success when AI generation or GitHub/GitLab file pushes fail.
  • Deduplicate generated file paths, include repo URLs in push progress events, and create GitHub repos as private by default.
  • Charge scaffold and legacy analysis credits against the authenticated user instead of trusting request-body user IDs.
  • Make credit deductions atomic with a single conditional update + audit transaction insert.

Bug and impact

  • Build-app could create empty/partial/broken repositories while emitting a final done SSE event, causing users to trust failed builds.
  • Scaffold generation skipped credits when clients omitted userId, and the legacy analysis route could charge arbitrary body-supplied users.
  • Concurrent credit deductions could both pass the balance check and corrupt credit accounting.

Root cause

  • Remote push errors were logged but not thrown, AI generation errors were converted into placeholder files, and credit code trusted mutable request body fields plus read-modify-write balance updates.

Validation

  • pnpm exec tsc --noEmit
  • 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
  • Mocked runtime harness verified build-app dedupe/private repo success, terminal SSE errors with no done on push/generation failure, scaffold authenticated-user charging, legacy analyze authenticated-user charging, and atomic concurrent credit deductions.
Open in Web View Automation 

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

vercel Bot commented Jun 14, 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 14, 2026 11:09am
repofuse Ready Ready Preview, Comment, Open in v0 Jun 14, 2026 11:09am
v0-repo-app-architect Ready Ready Preview, Comment, Open in v0 Jun 14, 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