Skip to content

fix: production AI plan schema, SSO error handling, and Accelerate URL check - #31

Merged
Suharshit merged 1 commit into
mainfrom
fix/production-migrations-ai-plan-sso
Sep 16, 2026
Merged

Suharshit merged 1 commit into
mainfrom
fix/production-migrations-ai-plan-sso

Conversation

@Suharshit

Copy link
Copy Markdown
Owner

Summary

Fixes found while debugging production (project creation, AI chat, and spec generation failing on designdraftly.vercel.app).

Design agent: "No object generated: response did not match schema"

The plan prompt tells the model that when the canvas already has components it should list only the components to add, but designPlanSchema required at least one component (and non-empty strings). A request that added nothing new returned components: [], failed validation, failed the single retry the same way, and the turn ended with a generic error.

  • The model now fills designPlanDraftSchema (same fields, no non-empty rules — the same approach already used for list limits).
  • sanitizePlanDraft drops unnamed components and incomplete decisions and fills a missing role, responsibility, or summary. The stored designPlanSchema is unchanged, so existing sessions keep parsing.
  • When no component is left, the run aborts with PLAN_NOTHING_TO_ADD_MESSAGE, which the session route shows to the user as is.
  • withSchemaRetry logs finish reason, validation cause, and the start of the response on both attempts, so the next mismatch is diagnosable from logs.

Auth

signIn.sso / signUp.sso results were ignored, so a failed GitHub/Google redirect did nothing with no console output or message. Errors are now logged and shown on the card.

Prisma

lib/prisma.ts checked for prism+postgres://; Accelerate URLs start with prisma+postgres://. Production uses a plain postgres:// URL, so this was latent.

Already done outside this PR

The production database was missing the add_ai_sessions and add_project_spec migrations (Prisma P2022: Project.specMdPath does not exist). They were applied manually with prisma migrate deploy. Nothing runs migrations on deploy yet — follow-up.

Test plan

  • pnpm typecheck
  • eslint on changed files
  • sanitizePlanDraft: empty draft → null; partial draft → repaired and valid against designPlanSchema
  • After merge (Trigger.dev tasks deploy from main): an "add components" AI turn on an existing canvas in production
  • GitHub sign-in in production shows an error message if the redirect fails

🤖 Generated with Claude Code

- Design agent: the plan prompt tells the model to list only components to
  add, but the plan schema required at least one component, so "add to the
  existing canvas" turns failed with "response did not match schema" on both
  attempts. The model now fills a lenient draft schema; sanitizePlanDraft
  repairs or drops empty fields and aborts with a user-facing message when
  nothing is left to add.
- withSchemaRetry logs finish reason, validation cause, and the start of the
  response for both attempts.
- Sign-in/sign-up: errors from signIn.sso / signUp.sso are logged and shown on
  the card instead of being ignored.
- lib/prisma.ts: fix the Accelerate URL prefix check (prisma+postgres://).
- Progress tracker: record the production migration incident and these fixes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
draftly Ready Ready Preview Sep 16, 2026 5:02pm UTC

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4c26c448-c6a4-476f-8c78-b7922c349531


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Suharshit
Suharshit merged commit 81d0c0e into main Sep 16, 2026
5 checks passed
@Suharshit
Suharshit deleted the fix/production-migrations-ai-plan-sso branch September 16, 2026 18:28

This branch was successfully deployed

1 active deployment
Preview — 59f7380d Deployed Sep 16, 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