Rate limited API clients get a different error shape and no Retry-After #65
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When the API rate limiter denies a request it answers 429 with
{"error":"Too many requests"}, a bare string undererror, and discards the retry delay it already computed. Every other v1 error uses the nested envelope withmessageandcode, so a client written against the documented shape gets nothing usable, and it has no server hint for when to retry. An unmatched path answers a third shape,{"errors":{"detail":"Not Found"}}.Evidence
At
2f150f66:lib/aprsme_web/plugs/rate_limiter.ex:50matches{:deny, _retry_after}and drops the value, then:52rendersjson(%{error: error_message})with 429.lib/aprsme_web/controllers/api/v1/json/error_json.ex:9is the nested%{error: %{message: message, code: ...}}envelope every other v1 error uses.lib/aprsme_web/controllers/error_json.ex:13produces the%{errors: %{detail: ...}}shape for unmatched routes.lib/aprsme_web/live/api_docs_live.ex:818documents 429 with no body.Expected
One error envelope across
/api/v1, and 429 carriesRetry-Afterfrom the value the limiter already has.How to verify
Send 101 requests in a minute from one address and compare the 429 body and headers with the documented envelope. Then request an unknown path and compare the third shape.
Acceptance criteria
Retry-After.Effort: S
Lens: api