-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
checkin limits implementation #1696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Changes requested. Reviewed everything up to 7f29118 in 1 minute and 39 seconds
More details
- Looked at
491
lines of code in10
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. py/core/database/limits.py:93
- Draft comment:
The check forif not limits:
is redundant since_determine_limits_for
already ensures defaults are applied. Consider removing this check. - Reason this comment was not posted:
Confidence changes required:50%
The check_limits method in PostgresLimitsHandler has a redundant check for limits being None, as the _determine_limits_for method already ensures defaults are applied.
2. py/core/main/api/v3/users_router.py:110
- Draft comment:
Remove print statements used for debugging in theregister
function. These should not be present in production code. - Reason this comment was not posted:
Confidence changes required:50%
The print statements in the register function in users_router.py are likely for debugging and should be removed for production code.
3. py/tests/integration/test_users.py:37
- Draft comment:
Remove print statements used for debugging in theregister_and_return_user_id
function. These should not be present in production code. - Reason this comment was not posted:
Confidence changes required:50%
The print statements in the register_and_return_user_id function in test_users.py are likely for debugging and should be removed for production code.
Workflow ID: wflow_zold39gAouls2cFO
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
def merge_with_defaults( | ||
self, defaults: "LimitSettings" | ||
) -> "LimitSettings": | ||
return LimitSettings( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using or
to set defaults in merge_with_defaults
can lead to incorrect behavior if a limit is set to 0. Consider using a more explicit check to handle 0 as a valid limit.
logger.warning( | ||
f"Global per-minute limit exceeded for user_id={user_id}, route={route}" | ||
) | ||
raise ValueError("Global per-minute rate limit exceeded") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ValueError
for rate limit exceptions is not ideal. Consider defining a custom exception for rate limit violations to distinguish them from other errors.
Important
Implements rate limiting for database operations with configurable limits in
DatabaseConfig
, enforced byPostgresLimitsHandler
, and updates API and tests accordingly.LimitSettings
indatabase.py
to defineglobal_per_min
,route_per_min
, andmonthly_limit
.limits
,route_limits
, anduser_limits
toDatabaseConfig
indatabase.py
.PostgresLimitsHandler
inlimits.py
to manage request logging and limit checking.PostgresDatabaseProvider
inpostgres.py
to initializePostgresLimitsHandler
.r2r.toml
to include default and route-specific limits under[database.limits]
and[database.route_limits]
.config.py
to handle new limit settings during configuration loading.base_router.py
to enforce limits on API routes.test_users.py
to include tests for user registration and token refresh, ensuring compliance with new limits.This description was created by for 7f29118. It will automatically update as commits are pushed.