Skip to content

fix: X-RateLimit-Reset header carries float epoch (6 test failures) - #293

Open
Mukller wants to merge 3 commits into
laurentS:masterfrom
Mukller:fix/reset-header-float
Open

fix: X-RateLimit-Reset header carries float epoch (6 test failures)#293
Mukller wants to merge 3 commits into
laurentS:masterfrom
Mukller:fix/reset-header-float

Conversation

@Mukller

@Mukller Mukller commented Aug 22, 2026

Copy link
Copy Markdown

What

get_window_stats() returns a float epoch despite the local Tuple[int, int] annotation, so the X-RateLimit-Reset header carried microsecond precision: 1787439694.295415 instead of 1787439694. Truncated both assignment sites to int.

Impact

This was also the actual cause of 6 failing tests on current master (test_headers_breach and related header tests asserted integer reset values). With this patch:

pytest tests/  ->  103 passed, 0 failed

(previously 6 failed / 97 passed)

Note: my earlier triage comment on #271 attributed those failures to the starlette app.route removal — that was wrong, apologies for the noise; #271 remains a separate, still-unaddressed issue.

Closes none directly, but fully greens the test suite.

…riant

asyncio.iscoroutinefunction is deprecated since Python 3.14 and emits
a DeprecationWarning at import/call time (laurentS#263). inspect.iscoroutinefunction
is the drop-in replacement and is already used elsewhere in the codebase
(middleware.py).
The handler is sometimes registered for broader exception types (e.g.
ConnectionError when a Redis storage backend is unreachable, laurentS#253).
Those exceptions have no .detail attribute, so formatting the response
raised a secondary AttributeError that masked the original error.
Fall back to str(exc) instead.
get_window_stats() returns a float epoch despite the Tuple[int, int]
annotation, so the RESET header carried microsecond precision
('1787439694.295415' instead of '1787439694'). This also made six
header-related tests fail on current master.
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