fix(ADS-678): name the enterprise quota in the 429 message - #453
Conversation
The 429 handler hardcoded one message for every rate-limit response, telling enterprise push-key callers they had hit the limit on "the public version of Agent-Scan" and should contact sales to unlock enterprise features. When PC01 exhausted its enterprise budget this morning that message sent the on-call looking at auth and routing rather than at spend. A push key puts the scan on the enterprise budget and everything else on the public one, so the caller already knows which applies without reading the response body. The backend draws the same distinction in its own 429 detail. Co-authored-by: Cursor <cursoragent@cursor.com>
PR Summary by QodoShow enterprise quota guidance for push-key 429 responses
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. 429 test duplicates mock setup
|
Why
The 429 handler in
verify_api.pyhardcoded a single message for every rate-limit response:So an enterprise push-key caller who exhausts the enterprise budget is told they are on the public tier and should contact sales for enterprise features. That happened on PC01 this morning:
cost.24hforbudget:enterprisehit $530.86 against a $500/day cap, and the message pointed the investigation at auth and routing instead of at spend.How
A push key routes the scan to
/hidden/mcp-scan/analysis-machine, which the backend hardcodes tobudget=ENTERPRISE; everything else goes to the CLI route andget_budget_for_user, which yields the public tier. The caller therefore already knows which budget applies, with no need to parse the response body:The remedy sentence mirrors the backend's own 429 detail for that bucket ("Please contact support to increase your quota"), so the CLI and API now say the same thing.
Tests
Adds
test_429_with_push_key_names_the_enterprise_quota, asserting the enterprise wording and that "public version" is absent. The existing parametrized 429 case runs without a push key, so it still covers the public path unchanged.ruff,ruff-formatandmypypass on both files.tests/unit/test_verify_api.pygoes from 85 to 86 passing, with the same 8 pre-existing failures before and after.Follow-up worth considering
Keying off
push_keyis accurate for the two real cases but does not coverinternal_tier, which the backend can also return for internal principals. Reading the backend's 429detailwould be exact, butraise_for_status()discards the body, so it needs a small refactor of the error path.Made with Cursor