Repository navigation
Conversation
Old Windows main-process listing stormed this route (~120 qps fleet) without X-App-Platform/X-App-Version. Reuse with_rate_limit so Redis rejects before Firestore. Failure-Class: none
kodjima33
approved these changes
Aug 22, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Backend bug fix, confidence 5/5: real production incident (Windows listing storm), scoped diff (12 lines), CI green, test added, mirrors existing rate-limit pattern. Confirmed not fixed on main.
Git-on-my-level
added a commit
that referenced
this pull request
Aug 26, 2026
The (12, 60) per-uid cap on `action_items:list` shipped in #11965, but the serving revision carries RATE_LIMIT_BOOST=100, so get_effective_limit() resolves it to 1,200/60s and it has never fired once. Meanwhile ~82 stale omi-windows/1.0.0 clients hot-loop GET /v1/action-items at ~97 req/min/uid, which is 48.8% of every billable Firestore document read in the project (~$328/day marginal at $0.05395/100k). Add BOOST_EXEMPT_POLICIES, honored in get_effective_limit(): an exempt policy always serves its base limit and ignores the boost, including an explicitly passed boost= argument. Seeded with action_items:list only; the other ~40 policies keep the boost, and a test asserts that. This restores an already-approved cap rather than choosing a new number, needs no client release, and cuts the loop from ~97 to 12 req/min/uid (~88%, ~$290/day). Enforcement runs in Depends() before the handler, so a 429 costs one Cloud Run request and zero Firestore reads. The exemption list is env-escapable in the module's existing style: RATE_LIMIT_BOOST_EXEMPT="" puts every policy back under the boost and restores byte-for-byte today's behaviour via a Cloud Run env change on a new revision -- no build, no image push, no revert. Unknown names are resolved against RATE_POLICIES and dropped, so a typo cannot crash import. Tradeoff: stale Windows clients will now see 429s on /v1/action-items. Their data stays correct -- 12/min is still ~150x more often than the app's own post-fix 5-minute sync design (6524990). +10 unit tests: non-exempt policies still boost, the exempt policy binds at (12, 60) under RATE_LIMIT_BOOST=100, env override and typo handling, and the 429 carries X-RateLimit-Limit: 12 (the enforced cap, not 1,200). Co-authored-by: Claude Fable 5 <[email protected]>
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
Cap first-party
GET /v1/action-itemsat 12 requests / 60s / uid via existingwith_rate_limit(Redis, multi-instance). Rejects inDepends()before Firestore.Old Windows main-process
taskSyncEnginelisted this route in a tight loop (~120 qps fleet) with onlyAuthorization— noX-App-Platform/X-App-Version, so a version gate cannot see it. A global 429 would also hit Mac/mobile.12/min is above Mac/Flutter hydrate + a few pagination pages; a tight loop dies after 12 calls.
Does not force clients to update.
/idscensus is unchanged.Failure-Class
Failure-Class: none
Root Cause
Windows main-process listing storm on
GET /v1/action-itemswith no client version header. Instrumentedaction_items_listwas ~1k/day because Cloud Run backend is not scraped.How to Verify
test_action_items_list_caps_tight_loopsand existing router-policy scan.Retry-Afteron the 13th listing GET in a minute for one uid; Firestore read ops on this route should fall.Test Plan
test_rate_limitingrouter scan (CI)Risk Assessment
Medium — legitimate rapid pagination >12/min gets 429 for the rest of the window. First-party limiter fail-opens if Redis is down.
/idsand writes are not capped by this policy.