Skip to content

fix: show why resending the two-factor email code failed - #44055

Merged
dionisio-bot[bot] merged 2 commits into
developfrom
fix/2fa-email-resend-rate-limit-message
Dec 2, 2026
Merged

dionisio-bot[bot] merged 2 commits into
developfrom
fix/2fa-email-resend-rate-limit-message

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

When the server refuses "Resend email" on the email two-factor screen, the toast shows Error trying to send email: [object Object]. A user sees this after 5 resends in one minute (HTTP 429).

The modal put the error object into the {{message}} value of error-email-send-failed. Now it puts the text from getErrorMessage(error) there. The toast keeps the translated prefix and shows the reason from the server:

Error trying to send email: Too many requests. Please slow down. You must wait 26 seconds before trying this endpoint again. [error-too-many-requests]

The REST rate limit message started with "Error,", so the toast showed "Error" two times. The message in ApiClass.ts now starts with "Too many requests.". Every endpoint uses this message. The [error-too-many-requests] suffix does not change, so RegisterForm still finds the error.

Root cause

Decisions and gaps

  • Decision: keep the error-email-send-failed prefix, because it is the only translated part of the toast. The other option was to give the error to the toast directly, as other screens do. That removes the prefix, so the full toast is in English.
  • Gap: the error-too-many-requests i18n key still starts with "Error,". No client code shows it for REST errors, so this PR does not change the key and its 54 translations.
  • Gap: no automated test for the rate limit text, because the rate limiter is off in TEST_MODE. A local server returned the new text on the sixth call in one minute.

Issue(s)

Steps to test or reproduce

  1. Make sure that the API rate limiter is on, and log in as a user with email two-factor authentication.
  2. On the code screen, click "Resend email" 6 times in one minute.
  3. The last toast shows the time to wait, not [object Object].

Further comments

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where errors during two-factor email code resend could appear as “[object Object]”. Resend failures now display the reason provided by the server, while expired or missing challenges continue to show the authentication-expired message.
    • Removed the unnecessary “Error,” prefix from rate-limit messages. The wait time and remaining message details are unchanged.

@dionisio-bot

dionisio-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9a2a1b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The email two-factor modal now displays a formatted server-provided reason when a resend fails for a reason other than an expired or missing challenge. The REST rate-limit message no longer begins with “Error,”. A test covers a rate-limited response.

Changes

Two-factor resend errors

Layer / File(s) Summary
Update rate-limit message
apps/meteor/server/api/ApiClass.ts, .changeset/fine-olives-nail.md
The rate-limit rejection message removes the “Error,” prefix. The changeset records this edit and the resend toast fix.
Format and test resend errors
apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx, apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.spec.tsx
Non-expiration resend errors use getErrorMessage, with Something_went_wrong as the fallback. The test checks that the server-provided reason appears in the error toast. Expired or missing challenges continue to show the expiration message.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: tassoevan, kevlehman, dougfabris

Merge Risk: Minimal · up to dcf00

The two-factor resend toast now shows the server's reason instead of [object Object], and the rate-limit message no longer repeats "Error". No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: show why resending the two-factor email code failed" names the main change. The PR fixes the two-factor email resend toast that displayed [object Object] after a rate-limited (HTTP 429…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: show why resending the two-factor email code failed" names the main change. The PR fixes the two-factor email resend toast that displayed [object Object] after a rate-limited (HTTP 429) rejection, so it now shows the server's reason. The title also fits the related change to the REST rate-limit message in ApiClass.ts, which is a smaller part of the change set. The title is specific, concise, and follows the conventional commit prefix style.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Errors were encountered while retrieving linked issues.

Errors: 1

  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f8283f2-cff8-4468-b622-45003ec862b7
Commits

Reviewing files that changed from the base of the PR and between 9a2a1b9 and dcf007f.

Files selected for processing: 1

  • apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.spec.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 5

  • GitHub Check: CodeRabbit
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
  • GitHub Check: Layne Security Scan

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.11%. Comparing base (16cc19c) to head (dcf007f).
⚠️ Report is 34 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #44055      +/-   ##
===========================================
+ Coverage    74.96%   75.11%   +0.14%     
===========================================
  Files         5784     5805      +21     
  Lines       268218   268846     +628     
  Branches     51821    52285     +464     
===========================================
+ Hits        201080   201937     +857     
+ Misses       62345    62084     -261     
- Partials      4793     4825      +32     
Flag Coverage Δ
e2e 64.86% <0.00%> (-0.03%) ⬇️
e2e-api 52.06% <ø> (+0.83%) ⬆️
unit 73.93% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@flakiness-io

flakiness-io Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Test Results Summary

This comment shows the latest test results for this pull request.

Commit Status Test Results CI Runs
dcf007f ✅ Passed 840 passed · 14 skipped 9 runs

View full report

ℹ️ About Flakiness.io in GitHub

Your team has set up Flakiness.io pull request comments. This comment is updated when

  • The first test results arrive for this pull request
  • A later run reports more results for the same commit
  • A new commit is pushed and tested

Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit.

@ricardogarim

Copy link
Copy Markdown
Member Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review

@ricardogarim I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx">

<violation number="1" location="apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx:66">
P2: This catch handler can throw instead of showing any toast when the request rejects with an unrecognized error shape. Pass a translated fallback to `getErrorMessage`, so unexpected resend failures still produce the `error-email-send-failed` toast.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@ricardogarim
ricardogarim force-pushed the fix/2fa-email-resend-rate-limit-message branch from cc35626 to 7c28fce Compare December 1, 2026 02:49
@ricardogarim ricardogarim added this to the 9.2.0 milestone Dec 1, 2026
@ricardogarim
ricardogarim marked this pull request as ready for review December 1, 2026 11:15
@ricardogarim
ricardogarim requested review from a team as code owners December 1, 2026 11:15

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@ricardogarim
ricardogarim force-pushed the fix/2fa-email-resend-rate-limit-message branch from 0748583 to 9a2a1b9 Compare December 1, 2026 12:04
@ricardogarim
ricardogarim force-pushed the fix/2fa-email-resend-rate-limit-message branch from 9a2a1b9 to dcf007f Compare December 1, 2026 13:15

@Aryan9891 Aryan9891 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean fix in apps/meteor/client/components/TwoFactorModal/TwoFactorEmailModal.tsx and apps/meteor/server/api/ApiClass.ts!

  • Error extraction: Wrapping error with getErrorMessage(error, 'Something_went_wrong') prevents [object Object] interpolation in t('error-email-send-failed', { message }) when the server returns a structured error payload.
  • Rate-limit copy & tests: Removing the redundant "Error, " prefix in ApiClass.ts avoids "Error trying to send email: Error, too many requests...", and TwoFactorEmailModal.spec.tsx pins the rate-limited toast behavior cleanly.

@ricardogarim ricardogarim added the stat: QA assured Means it has been tested and approved by a company insider label Dec 2, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 2, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into develop with commit fe87fe8 Dec 2, 2026
71 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/2fa-email-resend-rate-limit-message branch December 2, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants