fix: Avoid using prisma types on client#23566
Conversation
Walkthrough
Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/lib/redactError.ts (2)
7-9: Tighten Prisma detection; avoid false positives and cover more cases.Anchor the regex and fall back to constructor.name and known
P####codes. This avoids matching e.g. “Prismatic*” and still catches Prisma errors without importing Prisma.-function shouldRedact(error: Error) { - const n = error.name || ""; - return /Prisma/i.test(n); -} +function shouldRedact(error: Error) { + const name = error.name ?? (error as any)?.constructor?.name ?? ""; + if (/^Prisma/i.test(name)) return true; + const code = (error as any)?.code; + return typeof code === "string" && /^P\d{4}$/.test(code); +}
16-19: JSON.stringify(Error) yields {}; log structured fields and short‑circuit on prod first.Current logs drop details; also reorder condition for better DCE. No behavior change.
- log.debug("Type of Error: ", error.constructor); - if (shouldRedact(error) && IS_PRODUCTION) { - log.error("Error: ", JSON.stringify(error)); + log.debug({ msg: "Type of Error", name: error.name, ctor: error.constructor?.name }); + if (IS_PRODUCTION && shouldRedact(error)) { + log.error({ msg: "Prisma error redacted", name: error.name, code: (error as any).code, stack: error.stack }); return new Error("An error occurred while querying the database."); }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/lib/redactError.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/lib/redactError.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
packages/lib/redactError.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
packages/lib/redactError.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: Udit-takkar
PR: calcom/cal.com#22919
File: packages/features/calAIPhone/providers/retellAI/services/PhoneNumberService.ts:212-220
Timestamp: 2025-08-08T10:26:13.362Z
Learning: In calcom/cal.com PR #22919, packages/features/calAIPhone/providers/retellAI/services/PhoneNumberService.ts should include the phone number in client-facing HttpError messages (e.g., in updatePhoneNumber/getPhoneNumber catch blocks). Do not suggest redacting the phone number from these errors unless requirements change (per maintainer: Udit-takkar).
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Install dependencies / Yarn install & cache
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
packages/lib/redactError.ts (2)
1-6: Good call removing Prisma dependency from this module.This eliminates the client-bundle pull-in via barrel exports.
1-23: No Prisma imports detected in redactError or FE error boundaries
Validated thatpackages/lib/redactError.tsand all FE-facing error boundaries (apps/web/app/error.tsx,apps/web/pages/_error.tsx) contain no@prisma/clientor@calcom/prisma/clientimports.
E2E results are ready! |
What does this PR do?
Changes the
redactErrorto avoid importing Prisma to client due to barrel export at @calcom/prisma/client. The types itself are not a problem however it requires import of Prisma instance.