Conversation
WalkthroughThe change modifies apps/web/src/server/api/routers/contacts.ts. In the updateContactBook mutation, the input is deconstructed to extract contactBookId, and the remaining fields are passed as the update payload to the service, omitting contactBookId from the payload. Control flow and error handling are unchanged. There are no alterations to exported/public signatures. Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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. Comment |
|
@vamsi4845 is attempting to deploy a commit to the kmkoushik's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/server/api/routers/contacts.ts (1)
77-91: Replaceinput.contactBookIdwithcontactBook.idThe
contactsquery’s input schema doesn’t includecontactBookId, soinput.contactBookIdis alwaysundefined. Use the loadedcontactBook.idfrom context instead:const whereConditions: Prisma.ContactFindManyArgs["where"] = { - contactBookId: input.contactBookId, + contactBookId: contactBook.id, ...(input.subscribed !== undefined ? { subscribed: input.subscribed } : {}), ...(input.search ? { OR: [ { email: { contains: input.search, mode: "insensitive" } }, { firstName: { contains: input.search, mode: "insensitive" } }, { lastName: { contains: input.search, mode: "insensitive" } }, ], } : {}), };
🧹 Nitpick comments (1)
apps/web/src/server/api/routers/contacts.ts (1)
54-55: Fix correctly resolves the Prisma error.The destructuring approach properly excludes
contactBookIdfrom the update payload, preventing the "Unknown argument" error. The pattern is consistent with theupdateContactmutation (lines 148-150).Consider removing
contactBookIdfrom the input schema (line 47) since:
contactBookProcedurealready validates and providescontactBookin context- The value is never used (destructured but discarded)
- It reduces the API surface and prevents confusion
Similar cleanup could apply to
deleteContactBook(line 59).updateContactBook: contactBookProcedure .input( z.object({ - contactBookId: z.string(), name: z.string().optional(), properties: z.record(z.string()).optional(), emoji: z.string().optional(), }) ) .mutation(async ({ ctx: { contactBook }, input }) => { - const { contactBookId, ...data } = input; - return contactBookService.updateContactBook(contactBook.id, data); + return contactBookService.updateContactBook(contactBook.id, input); }),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/src/server/api/routers/contacts.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Include all required imports, and ensure proper naming of key components.
Files:
apps/web/src/server/api/routers/contacts.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript with 2-space indentation and semicolons (enforced by Prettier)
ESLint must pass with zero warnings using @usesend/eslint-config
Do not use dynamic imports (avoid import() and dynamic loading)
Files:
apps/web/src/server/api/routers/contacts.ts
**/*.{ts,tsx,md}
📄 CodeRabbit inference engine (AGENTS.md)
Format code and docs with Prettier 3
Files:
apps/web/src/server/api/routers/contacts.ts
apps/web/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
apps/web/**/*.{ts,tsx}: In apps/web, use the "/" alias for src imports (e.g., import { x } from "/utils/x")
Prefer using tRPC for API calls unless explicitly instructed otherwise
Files:
apps/web/src/server/api/routers/contacts.ts
|
TYSM |
Issue: The contactBookId was being passed to Prisma's update method as part of the data object, but it's not an updatable field, causing an "Unknown argument" error.
Fix: Destructured contactBookId out of the input(because middleware needs Id to lookup) , so only valid update fields reach Prisma
Before
chrome_wKtNAfkpRe.mp4
After
chrome_g6QwBiNiMB.mp4
Summary by CodeRabbit
Bug Fixes
Refactor