Skip to content

fix: show readable server errors in the error alert - #7789

Draft
Rohit3523 wants to merge 1 commit into
developfrom
fix/error-alert-messages
Draft

Rohit3523 wants to merge 1 commit into
developfrom
fix/error-alert-messages

Conversation

@Rohit3523

Copy link
Copy Markdown
Member

Proposed changes

showErrorAlertWithEMessage only read e.data.error and showed it as is. That goes wrong in two ways:

  • A REST error shows the English text with its error code in brackets, for example User not found [error-user-not-found].
  • A DDP method error has no data, so the message is undefined and the alert is blank.

The helper now reads the error code (data.errorType on REST, a string error on DDP) and the text (data.error, then reason, then message):

Error Alert text
REST, code has a translation the translation
REST, code has no translation the server's English text without the [code] suffix
DDP, code has a translation the translation
DDP, code has no translation the reason, or the message without the suffix
DDP, numeric code (for example 404) the reason
[error-too-many-requests] unchanged, with the seconds to wait
Two-factor prompt cancelled unchanged, no alert

The server throws new Meteor.Error('<code>', '<English reason>') and never translates the reason, and the app's en.json has only a few of those codes (error-not-allowed, error-action-not-allowed). So a code is used only when the app has a translation for it. Otherwise the server's English text is shown, never the raw code.

Issue(s)

Follow-up to #7783, where this came up in review. No ticket yet.

How to test or reproduce

  • pnpm test app/lib/methods/helpers/__tests__/info.test.ts
  • In the app, make the server reject a request from a screen that uses this alert (Status, Notification Preferences or Push Troubleshoot) and check the alert text has no [error-...] suffix. Where the app has a translation for the code, it is shown translated.

Not yet verified on a device or against a live server.

Screenshots

No UI change beyond the alert text.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

  • Removing the [code] suffix changes the text of the alerts the three existing callers show (StatusView, NotificationPreferencesView, PushGatewayConnection).
  • chore: migrate DDP methods to REST endpoints #7783 also adds the reason/message fallback to this function, so whichever of the two merges second needs a small rebase in info.ts.
  • The error shapes were checked against Rocket.Chat 8.10.0-develop (server/api/ApiClass.ts, server/meteor-methods/rooms/addUsersToRoom.ts), not against a live request.
  • The full test suite passes except .github/scripts/__tests__/changed-runner.test.js (missing-maestro guard), which fails on machines that have maestro on the PATH and is unrelated to this change.

REST errors keep their bracketed code in the alert and DDP errors have no data, so the alert is blank. The helper now reads the error code and text from either shape, shows the translation when the app has one for the code, and otherwise shows the server's text without the bracketed code.
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

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

This branch is waiting to be deployed

3 waiting deployments
android_build — e61a90a0 Waiting Oct 9, 2026 by Rohit3523 via Build Android / Hold #7153
ios_build — e61a90a0 Waiting Oct 9, 2026 by Rohit3523 via Build iOS / Hold #7153
approve_e2e_testing — e61a90a0 Waiting Oct 9, 2026 by Rohit3523 via E2E Hold #7153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant