Skip to content

🛡️ feat: Rate Limiting for Conversation Forking #8269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 5, 2025

Conversation

danny-avila
Copy link
Owner

Summary

I implemented fork rate limiters on the API to limit conversation forking requests per IP and user, improved error feedback and logging, and clarified error messages for downstream users.

  • Added forkIpLimiter and forkUserLimiter middleware to the /fork route to prevent abuse, with configuration via environment variables and Redis support for distributed tracking
  • Updated the Fork UI to show a specific error message when user exceeds the fork rate limit (HTTP 429)
  • Added a new translation string for the fork rate limit error
  • Improved error logging when fetching conversations by using the logger from the new data-schemas package for consistency
  • Updated error message for MeiliMongooseModel.deleteMany to clarify that a slow startup may trigger syncing due to deletion issues, making warnings more actionable
  • Refactored limiter utility imports for better maintainability by using utilities from their respective package modules
  • Suggested testing the fork rate limit system by attempting to fork conversations rapidly from both a single user and IP address, ensuring error messages are delivered as expected and Redis integration is functional if enabled

Test Configuration:

  • Unit tested fork limiters in isolation
  • Manually tested by forking conversations beyond the configured rate limits and verified correct error message appears in UI
  • Verified error logs are generated when exceptions occur in fetching conversations

Change Type

  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • I have made pertinent documentation changes
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes

@danny-avila danny-avila merged commit 97a9998 into dev Jul 5, 2025
7 checks passed
@danny-avila danny-avila deleted the feat/fork-limiters branch July 5, 2025 19:02
miguelwon pushed a commit to miguelwon/LibreChat that referenced this pull request Jul 9, 2025
* chore: Improve error logging for fetching conversations, and use new TS packages for utils

* feat: Implement fork limiters for conversation forking requests

* chore: error message for conversation index deletion to clarify syncing behavior

* feat: Enhance error handling for forking with rate limit message
lihe8811 pushed a commit to lihe8811/LibreChat that referenced this pull request Jul 15, 2025
* chore: Improve error logging for fetching conversations, and use new TS packages for utils

* feat: Implement fork limiters for conversation forking requests

* chore: error message for conversation index deletion to clarify syncing behavior

* feat: Enhance error handling for forking with rate limit message
kenshinsamue pushed a commit to intelequia/LibreChat that referenced this pull request Aug 4, 2025
* chore: Improve error logging for fetching conversations, and use new TS packages for utils

* feat: Implement fork limiters for conversation forking requests

* chore: error message for conversation index deletion to clarify syncing behavior

* feat: Enhance error handling for forking with rate limit message
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