Skip to content

Add Retry-After to rate-limited responses - #355

Open
teta2k wants to merge 1 commit into
mainfrom
fix/rate-limiting-retry-after
Open

Add Retry-After to rate-limited responses#355
teta2k wants to merge 1 commit into
mainfrom
fix/rate-limiting-retry-after

Conversation

@teta2k

@teta2k teta2k commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • add a numeric Retry-After header to the default 429 rate-limit response
  • use the rate limiter's existing time_remaining value for the delay
  • document the default header and cover it in responder and Rack middleware tests

Root cause

The rate limiter already attached the remaining window to request.env["aikido.rate_limiting"], but the default responder discarded that information and returned only Content-Type. As a result, clients received a 429 without knowing when to retry.

Custom rate_limited_responder callbacks are unchanged.

Validation

  • config, Rack middleware, and Action Controller tests: 50 tests, 312 assertions, 0 failures
  • StandardRB on all changed Ruby files
  • firewall-tester-action Compose test-rate-limiting-retry-after: passed in 5.05 seconds against the latest Ruby demo app using this branch as a local path dependency

Before this change, the same Compose test reported five rate-limited responses without a Retry-After header.

@teta2k
teta2k marked this pull request as ready for review August 6, 2026 16:01
@aikido-pr-checks

Copy link
Copy Markdown

Summary by Aikido

Security Issues: 0 Quality Issues: 0 Resolved Issues: 0

⚡ Enhancements

  • Added numeric Retry-After headers to default rate-limited responses

📚 Documentation

  • Documented default Retry-After behavior for rate-limited responses

More info

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hansott
hansott requested a review from marksmith August 7, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant