Skip to content

regression: add rate limiters to the thread REST endpoints - #41984

Merged
dionisio-bot[bot] merged 1 commit into
release-8.8.0from
regression/thread-endpoints-rate-limit
Aug 28, 2026
Merged

regression: add rate limiters to the thread REST endpoints#41984
dionisio-bot[bot] merged 1 commit into
release-8.8.0from
regression/thread-endpoints-rate-limit

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Aug 28, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Two of the thread pane's data sources moved off DDP during the 8.8.0 cycle and landed on REST endpoints that never declared rateLimiterOptions, so they inherited the default REST rule — 10 calls per 60 seconds per IP, a ceiling designed for machine-to-machine traffic. No call site changed, only the budget.

Neither DDP method had a dedicated rule, so both ran on the generic per-method limits in apps/meteor/server/startup/rateLimiter.js: Connection_By_Method (10 / 10s per connection) and User_By_Method (20 / 10s per user), both applied at once. This PR restores the per-user ceiling on all three thread routes.

Endpoint Moved to REST in Before After the migration This PR
POST /v1/chat.readThread #41593 (was readThreads DDP) 20 / 10s per user 10 / 60s per IP 20 / 10s per IP
GET /v1/chat.getThreadMessages #40998 (was getThreadMessages DDP) 20 / 10s per user 10 / 60s per IP 20 / 10s per IP
GET /v1/chat.getThreadsList always REST 10 / 60s per IP 10 / 60s per IP 20 / 10s per IP

Why the per-user rule and not the per-connection one. The REST limiter keys on IP, a coarser bucket than a DDP connection — one tab was one connection, and a user with two tabs had two 10-call buckets under a shared 20-call ceiling. Copying the per-connection number onto an IP key would be stricter than DDP ever was, and would fail this ticket's own reproduction: 11 replies arriving as a burst is 11 calls in one window, which 10/10s rejects exactly like 10/60s does.

chat.getThreadsList is not part of the regression — it has been REST since 2022 and has no earlier value to restore. It is included because it is the third leg of the same pane with the same paginated shape, so leaving it on 10/60s would just move the failure one panel over. It can be dropped without affecting the reported bug.

Issue(s)

CORE-2649

Steps to test or reproduce

chat.readThread (the reported case):

  1. Enable API_Enable_Rate_Limiter; leave the defaults at 10 calls / 60000 ms.
  2. As user A, open a thread and keep it open.
  3. As user B, send 11 replies to that thread within 60 seconds.
  4. Watch A's network tab: before this change, the 11th POST /api/v1/chat.readThread returns 429; after it, all succeed. A's tunread should not retain the thread's tmid.

chat.getThreadMessages — open 11 different threads within 60 seconds (each open costs one page request). Before this change the 11th thread fails to load its replies; after it, all open normally. Same result by dragging the scrollbar of a single thread past ~550 replies.

Further comments

1. Per-user keying (follow-up: CORE-2637). This restores the DDP budget, but keyed on IP, not userId — all the REST limiter can do today. A single user is now at or above what DDP gave them; users sharing a NAT still share one bucket. These three routes should switch over once per-user keying lands.

2. The migration guide needs updating in the meantime. docs/api-endpoint-migration.md never mentions carrying the method's rate limit over, which is what produced both this regression and CORE-2629. It needs a step: copy the method's dedicated RateLimiter.limitMethod rule, or if it had none, declare rateLimiterOptions explicitly — the REST default is a machine-to-machine ceiling, not a UI one.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Added request rate limits to thread-reading and thread-listing endpoints, allowing up to 20 requests every 10 seconds.

@dionisio-bot

dionisio-bot Bot commented Aug 28, 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 Aug 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9daaaa8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@ricardogarim ricardogarim added this to the 8.8.0 milestone Aug 28, 2026
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e6c34b2-dff4-4f99-b4f2-43e08b02fd33

📥 Commits

Reviewing files that changed from the base of the PR and between d0ed77e and 9daaaa8.

📒 Files selected for processing (1)
  • apps/meteor/server/api/v1/chat.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (17)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (1/4)
  • GitHub Check: 🔨 Test API Livechat (FIPS) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (2/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (4/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (1/5)
  • GitHub Check: 🔨 Test API Livechat (EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (4/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (5/5)
  • GitHub Check: 🔨 Test API Apps (deno-runtime - EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.0 coverage (3/5)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (3/4)
  • GitHub Check: 🔨 Test API (CE) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test API (FIPS) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test API Livechat (CE) / MongoDB 8.0 (1/1)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.0 (2/4)
  • GitHub Check: 🔨 Test API (EE) / MongoDB 8.0 coverage (1/1)
  • GitHub Check: 🔨 Test Federation Matrix
🧰 Additional context used
📓 Path-based instructions (2)
The main Rocket.Chat Meteor application resides in `apps/meteor/`; place its application code there rather than in other monorepo areas.

📄 CodeRabbit inference engine (CLAUDE.md)

Files:

  • apps/meteor/server/api/v1/chat.ts
Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Files:

  • apps/meteor/server/api/v1/chat.ts
🔇 Additional comments (1)
apps/meteor/server/api/v1/chat.ts (1)

263-263: LGTM!

Also applies to: 1062-1062, 1191-1191


Walkthrough

Three chat REST endpoints now limit requests to 20 per 10 seconds through rateLimiterOptions. No other endpoint logic changed.

Changes

Chat endpoint rate limiting

Layer / File(s) Summary
Configure chat endpoint rate limits
apps/meteor/server/api/v1/chat.ts
chat.readThread, chat.getThreadsList, and chat.getThreadMessages now allow 20 requests per 10 seconds.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 9daaa

The change is localized to restoring rate limits for the thread endpoints, and no actionable merge-blocking risk remains beyond normal checks and review.

Suggested labels: type: bug

Suggested reviewers: sampaiodiego, jessicaschelly, ggazzo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding rate limiters to the thread REST endpoints.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

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

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

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-8.8.0@d0ed77e). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.8.0   #41984   +/-   ##
================================================
  Coverage                 ?   69.38%           
================================================
  Files                    ?     4254           
  Lines                    ?   168911           
  Branches                 ?    30113           
================================================
  Hits                     ?   117191           
  Misses                   ?    46570           
  Partials                 ?     5150           
Flag Coverage Δ
e2e 58.79% <ø> (?)
e2e-api 45.89% <ø> (?)
unit 71.30% <ø> (?)

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.

@ricardogarim
ricardogarim marked this pull request as ready for review August 28, 2026 13:28
@ricardogarim
ricardogarim requested a review from a team as a code owner August 28, 2026 13:28

@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 1 file

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

Re-trigger cubic

Comment thread apps/meteor/server/api/v1/chat.ts
@FragaKrummenauer FragaKrummenauer added the stat: QA assured Means it has been tested and approved by a company insider label Aug 28, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 28, 2026
@dionisio-bot
dionisio-bot Bot merged commit 291f54e into release-8.8.0 Aug 28, 2026
56 checks passed
@dionisio-bot
dionisio-bot Bot deleted the regression/thread-endpoints-rate-limit branch August 28, 2026 18:51
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.

3 participants