Repository navigation
Use the standard error format for 429 responses and send Retry-After - #763
Merged
marcvergees merged 1 commit intoNov 10, 2026
Merged
Conversation
The rate limit handler answered {success, error, message}, unlike every
other error ({error_code, message}). The frontend reads body.error first,
so users saw the raw code instead of the message. Return error_code and
message, plus retry_after_seconds and a Retry-After header taken from the
limiter's window, and document the 429 in the contracts.
Fixes fireform-core#762
marcvergees
approved these changes
Nov 10, 2026
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.
Fixes #762
Problem
The rate limit handler added in #761 answered 429 with
{"success": false, "error": "RATE_LIMIT_EXCEEDED", "message": ...}. Every other error uses{error_code, message, detail?}. As a result:extractErrorMessagereadsbody.errorfirst, so a rate-limited user saw the raw code "RATE_LIMIT_EXCEEDED" instead of the message.Change
app/api/middleware/rate_limiter.py: the 429 body is now{"error_code": "RATE_LIMIT_EXCEEDED", "message": "Too many requests. Limit: 10 per 1 minute", "retry_after_seconds": N}, and the response includes a matchingRetry-After: Nheader.Nis read from the limiter's current window (the sameget_window_statscall slowapi uses for its own headers), so it is the actual time until the limit resets. It falls back to 60 if that lookup fails.GET /templates,POST /templates/uploadandPOST /forms/fill.retry_after_secondsinErrorResponsenow mentions 429.The limits themselves are unchanged.
Tests
test_rate_limit_forms_fillnow checks the new body, that the oldsuccess/errorkeys are gone, and that theRetry-Afterheader matchesretry_after_seconds. It fails ondevelopmentwithKeyError: 'error_code'.GET /templatesand a 3-second wait, the 11th returns429,Retry-After: 57,{'error_code': 'RATE_LIMIT_EXCEEDED', 'message': 'Too many requests. Limit: 10 per 1 minute', 'retry_after_seconds': 57}.ruff check app/is clean.