Files
buzz/docs
Tom Brow 81b4054e5d fix(push-gateway): answer 429, not 404, when the delivery quota is exhausted (#9803)
When an endpoint's delivery quota is exhausted, both authority stores
returned `AuthorityError::Rejected`, so `/v1/deliveries` answered `404
invalid_grant`. NIP-PL already specifies `429 {"error":"rate_limited"}`
for this case.

The 404 matters because the relay treats a 404 on a retry attempt as a
terminal replay and completes the wake, so a throttled wake was silently
dropped. On a first attempt it failed the wake. A 429 takes the relay's
existing retry-with-backoff path instead.

### Change
- Memory and Postgres stores return `RateLimited` on quota exhaustion.
`http.rs` already maps that to `429 rate_limited`.
- The rate-limited attempt still charges no quota and consumes no
auth-event or request-id fence, so the relay's retry with the same
request id is admitted once the window reopens.
- No doc change: NIP-PL and the deployment doc already describe 429.

### Validation
- Memory store: an exhausted quota returns `RateLimited`, leaves replay
rows and the quota counter unchanged, and the same auth event and
request id are admitted after the window.
- Postgres (ignored test, run locally against a temporary database): the
quota-ceiling race test now also asserts the loser is `RateLimited`.
- HTTP: the eleventh delivery under a quota of ten answers `429
{"error":"rate_limited"}` and reaches no transport.
- With the two store lines reverted, all three tests fail.

### Regressions
None expected. Only the quota-exhaustion result changes; grant,
authority and replay failures still collapse to `404 invalid_grant`.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-20 20:28:35 +00:00
..