fix: pass error message string instead of Error object to toast dispatcher #40244
fix: pass error message string instead of Error object to toast dispatcher #40244Naetiksoni08 wants to merge 2 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughNormalized error-to-string conversion for toast notifications across clipboard and composer-related components/hooks by using Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsx`:
- Line 30: The toast fallback should handle structured API error objects instead
of blindly String(error); in the ComposerJoinWithPassword handler where
dispatchToastMessage is called, detect if the caught value is a plain object
with fields like errorType and error (or message) and extract a readable message
(e.g., `${error.errorType}: ${error.error}` or error.message) before passing to
dispatchToastMessage; update the fallback branch that currently uses
String(error) to build and pass a descriptive string when the error is an
object, leaving existing Error-instance handling intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b9d70430-b6a8-4d04-b218-74e3527263ca
📒 Files selected for processing (7)
apps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsapps/meteor/client/views/room/composer/ComposerReadOnly.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx
🧠 Learnings (14)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
📚 Learning: 2026-02-24T19:16:35.307Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 39003
File: apps/meteor/client/lib/chats/flows/sendMessage.ts:39-45
Timestamp: 2026-02-24T19:16:35.307Z
Learning: In apps/meteor/client/lib/chats/flows/sendMessage.ts, when sdk.call('sendMessage', ...) throws an error, the message is intentionally left with temp: true (not deleted or cleaned up) to support a future retry UI feature. This allows users to retry sending failed messages rather than losing them.
Applied to files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx
📚 Learning: 2026-03-11T22:04:20.529Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 39545
File: apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts:59-61
Timestamp: 2026-03-11T22:04:20.529Z
Learning: In `apps/meteor/client/views/room/body/hooks/useHasNewMessages.ts`, the `msg.u._id === uid` early-return in the `streamNewMessage` handler is intentional: the "New messages" indicator is designed to notify about messages from other users only. Self-sent messages — including those sent from a different session/device — are always skipped, by design. Do not flag this as a multi-session regression.
Applied to files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsx
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.
Applied to files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsx
📚 Learning: 2026-04-10T22:42:05.539Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 40075
File: apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx:69-71
Timestamp: 2026-04-10T22:42:05.539Z
Learning: In `apps/meteor/client/views/room/modals/FileUploadModal/FileUploadModal.tsx`, the submit handler converts an empty/whitespace-only description to `undefined` (`description?.trim() || undefined`) intentionally. All downstream image-rendering components (`AttachmentImage`, `ImagePreview`, `ImageItem`, `ImageGallery`) default `undefined` alt to `''`, so the `<img alt="">` attribute is always present. Do not flag this `undefined` conversion as a bug preventing alt text from being cleared.
Applied to files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
apps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.
Applied to files:
apps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.ts
📚 Learning: 2026-04-14T21:10:31.855Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 36292
File: apps/meteor/client/hooks/useHasValidLocationHash.ts:7-12
Timestamp: 2026-04-14T21:10:31.855Z
Learning: When reviewing files in apps/meteor/client/hooks/, do not treat JSDoc-style comments on React hooks (especially exported hooks) as a violation of any “avoid code comments in implementation” guideline. It’s acceptable to use JSDoc to document the public API of exported hooks (e.g., parameter/return types, intended usage), as long as it documents behavior/contracts rather than adding narrative implementation comments.
Applied to files:
apps/meteor/client/hooks/useClipboardWithToast.ts
📚 Learning: 2026-03-03T11:11:48.541Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 39230
File: apps/meteor/app/api/server/v1/chat.ts:214-222
Timestamp: 2026-03-03T11:11:48.541Z
Learning: In apps/meteor/server/lib/moderation/reportMessage.ts, the reportMessage function validates that description is not empty or whitespace-only with `if (!description.trim())`. When migrating the chat.reportMessage endpoint to OpenAPI, adding minLength validation to the schema preserves this existing behavior.
Applied to files:
apps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.ts
📚 Learning: 2026-04-17T17:38:12.974Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 39858
File: packages/ui-kit/src/interactions/UserInteraction.ts:33-33
Timestamp: 2026-04-17T17:38:12.974Z
Learning: In RocketChat/Rocket.Chat (`packages/ui-kit/src/interactions/UserInteraction.ts`), `ViewSubmitUserInteraction` and `ViewClosedUserInteraction` intentionally do NOT include `rid` when the interaction originates from a **modal** surface. Modals are not scoped to a room, so no room id is available in that context. The `rid?: string` field is optional to support the contextual bar surface (where room context exists) while remaining absent for modals. Do not flag the absence of `rid` in modal viewSubmit/viewClosed interactions as a missing-context bug.
Applied to files:
apps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx
📚 Learning: 2026-04-17T18:33:24.670Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 39858
File: apps/meteor/tests/e2e/apps/uikit-interactions.spec.ts:123-151
Timestamp: 2026-04-17T18:33:24.670Z
Learning: In RocketChat/Rocket.Chat (`apps/meteor/tests/e2e/apps/uikit-interactions.spec.ts`), `executeBlockActionHandler` invocations originating from a **modal** surface intentionally do NOT include a `block_action_room` (room property) in the interaction payload. Modals are not scoped to a room, so no room id is available in that context. Do not flag the absence of a room assertion in the modal block-action test as a missing coverage bug; instead, document it explicitly with a `test.step` asserting the room entry is `undefined`.
Applied to files:
apps/meteor/client/views/room/composer/ComposerReadOnly.tsx
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.
Applied to files:
apps/meteor/client/views/room/composer/ComposerReadOnly.tsx
🔇 Additional comments (6)
apps/meteor/client/hooks/useClipboardWithToast.ts (1)
12-12: LGTM: the toast payload is now stringified.This avoids passing the raw
Errorobject into the toast dispatcher for clipboard failures.apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsx (1)
38-38: LGTM: error toast message normalization is correct here.The caught
Erroris converted to its message before dispatching the toast.apps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.ts (1)
29-29: LGTM: mutation errors now render readable toast text.The toast dispatcher receives a string instead of the
Errorobject.apps/meteor/client/views/room/composer/ComposerMessage.tsx (1)
37-37: LGTM: both composer failure paths now dispatch string messages.The join path preserves its rethrow behavior, and the send path preserves its existing handled-error behavior.
Also applies to: 64-64
apps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsx (1)
25-25: LGTM: the omnichannel join toast now receives a string.This matches the intended normalization pattern for
Errorinstances.apps/meteor/client/views/room/composer/ComposerReadOnly.tsx (1)
22-22: LGTM: read-only join errors are now toast-safe forErrorinstances.The mutation error path now passes a string message to the dispatcher.
|
Hey, just a gentle ping on this PR! 😊 I know everyone's busy. Happy to address any feedback or make changes if needed. |
Proposed changes (including videos or screenshots)
In multiple composer files and
useClipboardWithToast.ts, thedispatchToastMessagewas being called with anErrorobject directly as themessagefield:Since message expects a string, passing an Error object causes the toast to display [object Object] instead of the actual error message — making error toasts completely uninformative to the user.
Fix
This correctly extracts the error message string in all cases.
Files changed
apps/meteor/client/hooks/useClipboardWithToast.tsapps/meteor/client/views/room/composer/ComposerReadOnly.tsxapps/meteor/client/views/room/composer/ComposerMessage.tsxapps/meteor/client/views/room/composer/ComposerJoinWithPassword.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelInquiry.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/ComposerOmnichannelJoin.tsxapps/meteor/client/views/room/composer/ComposerOmnichannel/hooks/useResumeChatOnHoldMutation.tsSteps to test or reproduce
Further comments
Same pattern fixed across 7 files in the composer area.
Summary by CodeRabbit