Repository navigation
fix(api): use @repo/db for Prisma types and resolve schema generation… - #88
Conversation
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR migrates Prisma imports from ChangesPrisma import and error handling migration
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/src/controllers/form.controller.ts`:
- Around line 106-109: The Prisma error-code guard is duplicated in
form.controller.ts and should be centralized into a shared typed helper. Create
and use a reusable helper like isPrismaErrorCode(err, code) that encapsulates
the object/code check, then replace each repeated P2002/P2003-style guard in the
relevant controller methods with that helper to keep the logic consistent and
reduce duplication; also update the similar guard in onboarding.controller.ts to
use the same helper.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6a5870e6-51f1-48f9-b80f-bec18e18285e
📒 Files selected for processing (5)
apps/api/src/controllers/form.controller.tsapps/api/src/controllers/oauth.controller.tsapps/api/src/controllers/onboarding.controller.tsapps/api/src/controllers/response.controller.tsapps/api/src/controllers/template.controller.ts
📜 Review details
🔇 Additional comments (5)
apps/api/src/controllers/form.controller.ts (1)
1-1: LGTM!Also applies to: 106-109, 129-129, 170-170, 218-224, 407-410
apps/api/src/controllers/onboarding.controller.ts (1)
49-52: 🩺 Stability & Availability | ⚡ Quick winGuard against non-object thrown values before accessing
.code.Unlike the equivalent checks added in
form.controller.ts(which verifytypeof err === "object" && "code" in errfirst), this cast skips the runtime guard. If a non-object value (e.g.null) were ever thrown here,err.codewould throw and mask the original error.🛡️ Suggested fix
} catch (error) { // Unique constraint on username — can happen under concurrent requests - const err = error as { code?: string }; - if (err.code === "P2002") { + if (error && typeof error === "object" && "code" in error && error.code === "P2002") { res.status(409).json({ success: false, message: "Username is already taken" }); return; } - throw err; + throw error; }apps/api/src/controllers/response.controller.ts (1)
4-4: LGTM!apps/api/src/controllers/template.controller.ts (1)
1-1: LGTM!apps/api/src/controllers/oauth.controller.ts (1)
5-7: LGTM!
…error handling across controllers
Summary
Fix TypeScript compilation errors in template controller caused by Prisma schema mismatch. The Prisma client types were referencing models and fields that existed in the schema files but had not been generated.
Changes Made
@prisma/clientimports to@repo/dbin 3 controllers (template.controller.ts,form.controller.ts,response.controller.ts) for consistent dependency resolutionunknownerror type handling in catch blocks inform.controller.tsandonboarding.controller.ts— replacedinstanceof Prisma.PrismaClientKnownRequestErrorwith runtime type guardsRequestHandlertype annotation tooauthCallbackinoauth.controller.tsto fix inferred type portability errorsTesting
tsc --noEmitexits with 0 errorsRelated Issues
Checklist