🚦 fix: Add Rate Limiting to Conversation Duplicate Endpoint#12218
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds rate limiting to the conversation “duplicate” endpoint to align it with the existing “fork” protections and prevent abuse.
Changes:
- Apply existing
forkIpLimiterandforkUserLimitermiddleware toPOST /api/convos/duplicate. - Add a Jest/Supertest suite to verify duplicate-route rate limiting behavior (429 after exceeding limits).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
api/server/routes/convos.js |
Adds fork IP/user rate limiting middleware to the /duplicate route. |
api/server/routes/__tests__/convos-duplicate-ratelimit.spec.js |
Introduces tests asserting rate limiting is active and enforced on /duplicate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -280,7 +280,7 @@ router.post('/fork', forkIpLimiter, forkUserLimiter, async (req, res) => { | |||
| } | |||
| }); | |||
|
|
|||
| router.post('/duplicate', async (req, res) => { | |||
| router.post('/duplicate', forkIpLimiter, forkUserLimiter, async (req, res) => { | |||
Comment on lines
+3
to
+8
|
|
||
| process.env.FORK_USER_MAX = '2'; | ||
| process.env.FORK_USER_WINDOW = '1'; | ||
| process.env.FORK_IP_MAX = '100'; | ||
| process.env.FORK_IP_WINDOW = '1'; | ||
|
|
Comment on lines
+131
to
+140
| it('should have rate limiting middleware on the /duplicate route', () => { | ||
| const convosRouter = require('../convos'); | ||
| const duplicateLayer = convosRouter.stack.find( | ||
| (layer) => layer.route?.path === '/duplicate' && layer.route?.methods?.post, | ||
| ); | ||
|
|
||
| expect(duplicateLayer).toBeDefined(); | ||
| expect(duplicateLayer.route.stack.length).toBeGreaterThanOrEqual(3); | ||
| }); | ||
|
|
danny-avila
force-pushed
the
fix/sec-convos-ratelimit
branch
from
March 14, 2026 01:57
2fcc476 to
0881320
Compare
- Consolidated mock implementations into a dedicated `convos-route-mocks.js` file to enhance maintainability and readability of test files. - Updated tests in `convos-duplicate-ratelimit.spec.js` and `convos.spec.js` to utilize the new mock structure, improving clarity and reducing redundancy. - Enhanced the `duplicateConversation` function to accept an optional title parameter for better flexibility in conversation duplication.
jcbartle
pushed a commit
to jcbartle/LibreChat
that referenced
this pull request
May 11, 2026
…ila#12218) * fix: add rate limiting to conversation duplicate endpoint * chore: linter * fix: address review findings for conversation duplicate rate limiting * refactor: streamline test mocks for conversation routes - Consolidated mock implementations into a dedicated `convos-route-mocks.js` file to enhance maintainability and readability of test files. - Updated tests in `convos-duplicate-ratelimit.spec.js` and `convos.spec.js` to utilize the new mock structure, improving clarity and reducing redundancy. - Enhanced the `duplicateConversation` function to accept an optional title parameter for better flexibility in conversation duplication. * chore: rename files
ThomasVuNguyen
pushed a commit
to ThomasVuNguyen/LibreChat
that referenced
this pull request
Jul 15, 2026
…ila#12218) * fix: add rate limiting to conversation duplicate endpoint * chore: linter * fix: address review findings for conversation duplicate rate limiting * refactor: streamline test mocks for conversation routes - Consolidated mock implementations into a dedicated `convos-route-mocks.js` file to enhance maintainability and readability of test files. - Updated tests in `convos-duplicate-ratelimit.spec.js` and `convos.spec.js` to utilize the new mock structure, improving clarity and reducing redundancy. - Enhanced the `duplicateConversation` function to accept an optional title parameter for better flexibility in conversation duplication. * chore: rename files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.