fix(buddy): clearer errors for /start 500 (Daily key + DB schema)#130
Conversation
- Missing DAILY_API_KEY: explicit message (was plain Error → 500) - Daily non-API failures: 503 + log, not 500 - DB update failures (e.g. missing daily_room columns): cleanup Daily room, 503 + migration hint - DB race still returns 409 after orphan room cleanup Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe error handling in the buddy session start route was expanded to handle Daily room creation failures (including name-conflict retries, API key issues, and generic errors) and database update failures (with Daily cleanup and specific schema error detection) with controlled HTTP responses instead of throwing exceptions. Changes
Sequence DiagramsequenceDiagram
participant Client
participant API as API Route
participant Daily as Daily API
participant DB as Database
Client->>API: Start buddy session
API->>Daily: Create room with prefix
alt Name Conflict (Retry)
Daily-->>API: Name conflict error
API->>Daily: Retry with different name
alt Retry Succeeds
Daily-->>API: Room created
else Retry Fails
Daily-->>API: Error logged
API-->>Client: 503 (retry failed)
end
else Missing DAILY_API_KEY
Daily-->>API: Error contains DAILY_API_KEY
API-->>Client: 503 (set DAILY_API_KEY)
else Generic Error
Daily-->>API: Other error
API-->>Client: 503 (unexpected error)
end
rect rgba(100, 200, 100, 0.5)
API->>DB: Transition to active state
alt DB Success
DB-->>API: Row updated
API-->>Client: 200 OK
else DB Schema Error (regex match)
DB-->>API: Error (daily_room/42703)
API->>Daily: Delete room (ignoreMissing)
Daily-->>API: Deletion complete
API-->>Client: 503 (run schema push)
else DB Other Error
DB-->>API: Unexpected error
API->>Daily: Delete room (ignoreMissing)
Daily-->>API: Deletion complete
API-->>Client: 503 (try again)
end
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Production readiness check for buddy
Exact Neon verification query: SELECT column_name, data_type
FROM information_schema.columns
WHERE table_schema='public'
AND table_name='buddy_sessions'
AND column_name IN ('daily_room_name','daily_room_url')
ORDER BY column_name;If schema drift is found, apply incremental SQL from ALTER TABLE "buddy_sessions" ADD COLUMN IF NOT EXISTS "daily_room_name" varchar(128);
ALTER TABLE "buddy_sessions" ADD COLUMN IF NOT EXISTS "daily_room_url" text;Follow-up tracking issue (includes checklist + exact SQL): Note: PR #130 is currently open, so code deploy is still required before confirming production behavior of the new 503 error mapping path. |
|
Production verification update (confirmed):
Environment + schema prerequisites for buddy |
Cause of
POST …/start500Most likely one of:
DAILY_API_KEYunset in Vercel —createRoomthrew a plainError, which was rethrown and became 500.daily_room_name/daily_room_url—UPDATE buddy_sessionsfails → 500 (often ifdrizzle-kit pushwas only run against dev).Change
errorstring (and log server-side).DailyApiErrorfrom Daily path: 503 instead of 500.What you should verify on prod
DAILY_API_KEYset.drizzle-kit pushwith prodPOSTGRES_URLordrizzle/buddy_sessions_daily_room_incremental.sql).After deploy, retry Start — UI should show the API
errormessage via existingApiErrorhandling.Made with Cursor
Summary by CodeRabbit
Release Notes