Repository navigation
fix(backend): rate-limit GET /v1/personas/twitter/initial-message (#12781) - #12784
Merged
kodjima33 merged 1 commit intoSep 5, 2026
Merged
Conversation
…2781) This is the only billable route in backend/routers/apps.py with neither a quota gate nor a rate limit: it runs a tracked LLM call (track_usage(uid, Features.PERSONA)) but track_usage only attributes spend, it does not block, so a free user past the monthly cap could call it indefinitely. Wire the same rate limiter its sibling generate-prompts already has (auth.with_rate_limit(..., "apps:twitter_initial_message"), 30/hour, matching apps:generate_prompts). Whether persona spend should also count against the chat quota is a separate billing-policy question the issue explicitly leaves to a maintainer -- this only adds the request bound, per the issue's own "cheapest correct step" framing. Tested: added test_twitter_initial_message_endpoint_rate_limited (fails on main, passes with this diff) plus updated test_all_router_policies_exist / test_apps_router_has_rate_limit. Ran the full backend/tests/unit/test_rate_limiting.py suite: 85 passed, 1 skipped (unrelated fakeredis-only test). Failure-Class: none 🤖 automated by hourly watchdog — tested and merged
kodjima33
deleted the
watchdog/issue-12781-twitter-initial-message-rate-limit
branch
September 5, 2026 07:44
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.
Summary
GET /v1/personas/twitter/initial-messageruns a billable, tracked LLM call (track_usage(uid, Features.PERSONA)) but had neither a quota gate nor a rate limit -- the only billable route inbackend/routers/apps.pywith neither (per #12781's own audit table).track_usageonly attributes spend, it does not block, so a free user past the monthly cap could call it indefinitely.This wires the same rate limiter its sibling
generate-promptsalready has:auth.with_rate_limit(auth.get_current_user_uid, "apps:twitter_initial_message"), 30/hour, matchingapps:generate_prompts. Whether persona spend should also count against the chat quota is a separate billing-policy question the issue explicitly defers to a maintainer -- this PR only adds the request bound, per the issue's own "cheapest correct step" framing.Test plan
test_twitter_initial_message_endpoint_rate_limitedinbackend/tests/unit/test_rate_limiting.py(fails onmain, passes with this diff), and updatedtest_all_router_policies_exist/test_apps_router_has_rate_limitfor the new policy.backend/tests/unit/test_rate_limiting.py: 85 passed, 1 skipped (unrelated fakeredis-only test, skips without the optional dependency on both main and this branch).Failure-Class: none
Line-Count-Exception: backend/routers/apps.py | 2468 -> 2471 | multi-line Depends() signature to fit the new rate-limit wrapper call within the line-length limit; no logic added beyond the one new Depends() dependency
🤖 automated by hourly watchdog — tested and merged