Skip to content

[#363] Fix role id + infinite loop on form update in UI#364

Merged
ncano1025 merged 2 commits intomainfrom
api/roleid-logging
Feb 13, 2026
Merged

[#363] Fix role id + infinite loop on form update in UI#364
ncano1025 merged 2 commits intomainfrom
api/roleid-logging

Conversation

@DGoel1602
Copy link
Contributor

@DGoel1602 DGoel1602 commented Feb 13, 2026

Why

Things breaking

What

Issue(s): #363

Things logging so they can be fixed

Test Plan

Please this is urgent

Checklist

  • Database: No schema changes, OR I have contacted the Development Lead to run db:push before merging
  • Environment Variables: No environment variables changed, OR I have contacted the Development Lead to modify them on Coolify BEFORE merging.

Summary by CodeRabbit

  • Refactor

    • Updated form editor API surface by removing an unused editor prop to simplify component usage.
  • Bug Fixes

    • Standardized error handling for role assignment to return consistent, descriptive error responses.

@DGoel1602 DGoel1602 self-assigned this Feb 13, 2026
@DGoel1602 DGoel1602 added Bug Something isn't working API Change modifies code in the global API/tRPC package labels Feb 13, 2026
@DGoel1602 DGoel1602 marked this pull request as ready for review February 13, 2026 20:45
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Removed updateFormMutation prop from the EditorClient component; standardized error handling in the addRoleId mutation by replacing thrown generic Error instances with TRPCError (code: "INTERNAL_SERVER_ERROR") and attaching the original error as cause.

Changes

Cohort / File(s) Summary
EditorClient Props
apps/blade/src/app/admin/forms/[slug]/client.tsx
Removed updateFormMutation from the destructured props of EditorClient, removing it from the component's public API.
TRPCError Standardization
packages/api/src/routers/misc.ts
Replaced thrown generic Error in addRoleId with TRPCError (code: "INTERNAL_SERVER_ERROR"); catch block now throws TRPCError with the original error as cause. Added TRPCError import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Blade

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows the required format with [#363] issue number and concisely describes two distinct fixes (role id and infinite loop), staying under 72 characters at 55 characters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main
No Hardcoded Secrets ✅ Passed PR modifications contain no hardcoded API keys, passwords, tokens, or secrets. Error messages use standard TRPC codes and environment variables are properly referenced.
Validated Env Access ✅ Passed Investigation found no direct process.env usage in modified files. Changes adhere to codebase pattern of using validated environment imports instead of raw process.env access.
No Typescript Escape Hatches ✅ Passed Both modified files contain zero instances of any type, @ts-ignore, @ts-expect-error, or non-null assertions. Changes improve type safety by replacing generic Error with proper TRPCError typing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch api/roleid-logging

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Inconsistent error handling: Use TRPCError here too.

The addRoleId mutation now uses TRPCError, but this procedure still throws a generic Error. Generic errors don't integrate well with tRPC's error handling — they'll be wrapped as INTERNAL_SERVER_ERROR instead of the more appropriate NOT_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.

@ncano1025 ncano1025 added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 030ec2f Feb 13, 2026
8 checks passed
@ncano1025 ncano1025 deleted the api/roleid-logging branch February 13, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API Change modifies code in the global API/tRPC package Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants