Bug Description
The rate_limit field in the Settings config is evaluated at class definition time instead of runtime. Because it depends on rate_limit_max_requests and rate_limit_window, changes from environment variables are not reflected, resulting in incorrect rate limit values.
To Reproduce
- Set in
.env:
RATE_LIMIT_MAX_REQUESTS=10
RATE_LIMIT_WINDOW=120
- Start the backend.
- Log or print
settings.rate_limit.
Expected Behavior
rate_limit should dynamically reflect the current values.
Example: 10 requests per 120s
Actual Behavior
The value remains 30 requests per 60s (default) even after env changes.
Screenshots/Logs
INFO: Loaded rate limit: 30 requests per 60s
Expected: 10 requests per 120s
Environment
OS: Windows 11
Shell: PowerShell 5.1
Node.js: 18.17.0
Python: 3.11.x
Coderrr: 1.1.0
Additional Context
This happens because rate_limit is a static class attribute instead of a computed property.
Checklist
Bug Description
The
rate_limitfield in the Settings config is evaluated at class definition time instead of runtime. Because it depends onrate_limit_max_requestsandrate_limit_window, changes from environment variables are not reflected, resulting in incorrect rate limit values.To Reproduce
.env:RATE_LIMIT_MAX_REQUESTS=10
RATE_LIMIT_WINDOW=120
settings.rate_limit.Expected Behavior
rate_limitshould dynamically reflect the current values.Example:
10 requests per 120sActual Behavior
The value remains
30 requests per 60s(default) even after env changes.Screenshots/Logs
INFO: Loaded rate limit: 30 requests per 60s
Expected: 10 requests per 120s
Environment
OS: Windows 11
Shell: PowerShell 5.1
Node.js: 18.17.0
Python: 3.11.x
Coderrr: 1.1.0
Additional Context
This happens because
rate_limitis a static class attribute instead of a computed property.Checklist
.env