fix(admin): surface API error message in toasts#1653
Conversation
Forward ConnectError.rawMessage into the toast description for the remaining admin catch blocks that previously showed only a generic error: project member removal, project rename, preference save, and webhook create/update/delete. Falls back to no description for non-ConnectError errors so behavior is unchanged for those.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR standardizes error toast descriptions across admin UI components by replacing ChangesError Toast rawMessage Standardization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Coverage Report for CI Build 26744068102Coverage remained the same at 43.06%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
…tions Refactor error handling across various admin components to display the rawMessage from ConnectError in toast notifications instead of the generic error message. This change enhances the clarity of error reporting for users.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
web/sdk/admin/views/organizations/details/edit/billing.tsx (1)
117-160:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAvoid double error toasts in billing update
updateBillingDetailsis awaited inonSubmitand the mutation has anonErrorhandler, so failures trigger both:
onErrorshowserror.rawMessage- the
catchblock shows the generic"Failed to update billing details"Remove the toast from the
catch(keep logging) to preserve the server error message.♻️ Proposed change (drop redundant catch toast)
} catch (error) { - toastManager.add({ - title: "Something went wrong", - description: "Failed to update billing details", - type: "error", - }); console.error("Failed to update billing details:", error); }web/sdk/admin/views/preferences/details.tsx (1)
241-248:⚠️ Potential issue | 🟡 Minor | ⚡ Quick win
data-test-idpassed toPreferenceValueis ignored.
PreferenceValueProps(lines 23-27) does not declaredata-test-id, andPreferenceValuedoes not forward it to the renderedInput/Switch. The attribute on Line 247 is a no-op; the input still carries the hardcodedadmin-preference-value-inputfrom Line 47. If the test hook needs to change, update the inner element instead.web/sdk/admin/views/users/details/security/sessions/revoke-session-final-confirm.tsx (1)
24-43:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftFix async error handling in revoke-session-final-confirm
Inweb/sdk/admin/views/users/details/security/sessions/revoke-session-final-confirm.tsx(handleConfirm),onConfirmis() => voidand is called synchronously inside atry/catchwithoutawait, so thiscatchonly handles synchronous throws—anyConnectErrorfrom an async revoke triggered byonConfirmwon’t reachhandleConnectError. Also,onOpenChange(false)closes the dialog immediately afteronConfirm()is kicked off. ChangeonConfirmto return aPromiseandawaitit before mapping errors/closing, or move async error handling to the caller where the revoke request is awaited.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: de7805df-2c12-4712-b731-5f336bf06105
📒 Files selected for processing (17)
web/sdk/admin/views/organizations/details/edit/billing.tsxweb/sdk/admin/views/organizations/details/edit/kyc.tsxweb/sdk/admin/views/organizations/details/layout/add-tokens-dialog.tsxweb/sdk/admin/views/organizations/details/layout/invite-users-dialog.tsxweb/sdk/admin/views/organizations/details/members/remove-member.tsxweb/sdk/admin/views/organizations/details/projects/members/remove-member.tsxweb/sdk/admin/views/organizations/details/projects/rename-project.tsxweb/sdk/admin/views/organizations/details/projects/use-add-project-members.tsxweb/sdk/admin/views/organizations/details/security/block-organization.tsxweb/sdk/admin/views/organizations/details/security/domains-list.tsxweb/sdk/admin/views/preferences/details.tsxweb/sdk/admin/views/users/details/security/block-user.tsxweb/sdk/admin/views/users/details/security/sessions/revoke-session-final-confirm.tsxweb/sdk/admin/views/users/list/invite-users.tsxweb/sdk/admin/views/webhooks/webhooks/create/index.tsxweb/sdk/admin/views/webhooks/webhooks/delete/index.tsxweb/sdk/admin/views/webhooks/webhooks/update/index.tsx
Summary
Admin toasts were either hiding the server's error reason behind a generic message, or showing it with the raw gRPC code prefix (e.g.
[failed_precondition] ...). This PR makes admin error toasts surface the clean, human-readable server message in the toastdescription.Two related changes:
error instanceof ConnectError ? error.rawMessage : undefinedintodescription.[code]prefix — toasts that already showed the server message viaerror.message(which connect-es formats as[code] message) now useerror.rawMessage(the message without the prefix).rawMessageis always a string on aConnectError, and every call is guarded, so behavior is unchanged for non-ConnectErrorerrors.Affected paths & the message users will now see
Newly surfaced (previously generic title only)
organizations/details/projects/members/remove-member.tsxremoveProjectMemberorganizations/details/projects/rename-project.tsxupdateProjectpreferences/details.tsxcreatePreferenceswebhooks/webhooks/create/index.tsxcreateWebhookwebhooks/webhooks/update/index.tsxupdateWebhookwebhooks/webhooks/delete/index.tsxdeleteWebhookPrefix removed (
[code] msg→ cleanmsg)organizations/details/members/remove-member.tsxremoveOrganizationMemberorganizations/details/security/block-organization.tsxdisable/enableOrganizationorganizations/details/security/domains-list.tsxdeleteOrganizationDomainorganizations/details/layout/add-tokens-dialog.tsxdelegatedCheckoutorganizations/details/layout/invite-users-dialog.tsxcreateOrganizationInvitationorganizations/details/edit/billing.tsxupdateBillingAccountDetailsorganizations/details/edit/kyc.tsxsetOrganizationKycorganizations/details/projects/use-add-project-members.tsxsetProjectMemberRoleusers/list/invite-users.tsxcreateOrganizationInvitationusers/details/security/block-user.tsxdisable/enableUserusers/details/security/sessions/revoke-session-final-confirm.tsxrevokeUserSession* These backend handlers currently map all failures to a generic
internal server error, so the description shows that until the backend returns more specific errors. This is no worse than the previous generic toast, and verified non-empty so the description never renders blank.Test plan
[failed_precondition]-style[code]prefix anymoreConnectErrorfailures still render a toast with no description (unchanged)🤖 Generated with Claude Code