fix(ratelimit): prune expired endpoint identities#454
Open
eshaanag wants to merge 1 commit into
Open
Conversation
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.
Summary
Closes #452
This PR fixes the unbounded growth in
EndpointRateLimiter.historywhen many different client identities make requests and then age out of the sliding window.What changed
Validation
PYTHONPATH=/tmp/secuscan_test_stubs venv_tests/bin/python -c 'import os, pytest; code = pytest.main(["testing/backend/unit/test_endpoint_rate_limiter.py", "-q", "-k", "prunes_expired_identity_buckets or cleanup_is_interval_bounded or sliding_window_limiting_logic or sliding_window_reset"]); os._exit(code)'venv_tests/bin/ruff check backend testing/backendgit diff --checkNote: the local full backend pytest run was attempted, but this machine cannot install the real
xhtml2pdfdependency because itspycairobuild needs system Cairo development headers and sudo is not available. The focused limiter tests and Ruff pass locally; CI should run the normal dependency path.Could you please add the appropriate GSSoC label/level for this contribution if it looks good?