Repository navigation
fix: rate limit the ask and live pull endpoints - #7
Conversation
POST /api/conf/{id}/ask and POST /api/conf/{id}/live/pull spend OpenAI,
Exa and Bright Data credits and had no limit. Generalize the in-memory
per-client limiter used by /note and apply it at 10 asks and 2 pulls per
60 s. The background live loop calls the pull directly and is not limited.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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. Comment |
PR Summary by QodoRate-limit costly ask and manual live-pull endpoints
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Venue guests share one question budget
|
| if not _allowed(_ask_hits, _client_ip(request), ASK_LIMIT, ASK_WINDOW): | ||
| raise HTTPException(429, "easy. ten questions a minute per person is plenty") |
There was a problem hiding this comment.
1. Venue guests share one question budget 🐞 Bug ≡ Correctness
ask() keys _ask_hits solely by _client_ip(request), so visitors behind the same public IP consume the same ten-request allowance. When attendees use a venue network with shared egress, ten questions from any combination of them cause subsequent attendees' questions to receive 429, even if those attendees have made no requests.
Agent Prompt
## Issue description
Visitors sharing a public IP also share the new ask budget, so one group can exhaust it for other attendees.
## Fix Focus Areas
- app/server.py[50-54]
- app/server.py[473-476]
## Recommended Fix
Use a visitor-specific identity for the ask budget, such as a server-issued signed session identifier, while retaining a separate, appropriately sized IP-level backstop against anonymous abuse.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
/ask and /live/pull spend OpenAI, Exa and Bright Data credits and had no limit. The per-client limiter from /note is now generic and applied at 10 asks and 2 pulls per 60 s; the background live loop calls an internal pull and is not limited. Verified with a TestClient run.