[#363] Fix role id + infinite loop on form update in UI#364
Conversation
📝 WalkthroughWalkthroughRemoved Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/api/src/routers/misc.ts (1)
137-139: 🛠️ Refactor suggestion | 🟠 MajorInconsistent error handling: Use
TRPCErrorhere too.The
addRoleIdmutation now usesTRPCError, but this procedure still throws a genericError. Generic errors don't integrate well with tRPC's error handling — they'll be wrapped asINTERNAL_SERVER_ERRORinstead of the more appropriateNOT_FOUND.For consistency and proper client-side error handling, switch to
TRPCError:♻️ Proposed fix
const team = TEAM.TEAMS.find((team) => team.team === input.team); if (!team) { - throw new Error("Team not found"); + throw new TRPCError({ + message: "Team not found", + code: "NOT_FOUND", + }); }
🤖 Fix all issues with AI agents
In `@packages/api/src/routers/misc.ts`:
- Around line 88-93: The condition in the route is inverted: currently it throws
when input.roleId IS in FORMS.ALLOWED_ASSIGNABLE_DISCORD_ROLES, preventing
allowed roles; change the check to throw when input.roleId is NOT in
FORMS.ALLOWED_ASSIGNABLE_DISCORD_ROLES. Update the TRPCError to use an
appropriate client-side code (e.g., "FORBIDDEN" or "BAD_REQUEST") and adjust the
error message to state the role is not assignable; locate the logic around
FORMS.ALLOWED_ASSIGNABLE_DISCORD_ROLES, input.roleId and the TRPCError
construction to make these changes.
Why
Things breaking
What
Issue(s): #363
Things logging so they can be fixed
Test Plan
Please this is urgent
Checklist
db:pushbefore mergingSummary by CodeRabbit
Refactor
Bug Fixes