fix: fail fast when RATE_LIMIT_BACKEND=redis but no Redis URL is configured
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Abhimanyu Saharan
parent
f1bcf72810
commit
dc25a9df6b
@@ -120,12 +120,19 @@ class Settings(BaseSettings):
|
|||||||
self.base_url = base_url.rstrip("/")
|
self.base_url = base_url.rstrip("/")
|
||||||
|
|
||||||
# Rate-limit: fall back to rq_redis_url if using redis backend
|
# Rate-limit: fall back to rq_redis_url if using redis backend
|
||||||
# with no explicit rate-limit URL.
|
# with no explicit rate-limit URL. If both are blank, fail fast
|
||||||
|
# with a clear configuration error.
|
||||||
if (
|
if (
|
||||||
self.rate_limit_backend == RateLimitBackend.REDIS
|
self.rate_limit_backend == RateLimitBackend.REDIS
|
||||||
and not self.rate_limit_redis_url.strip()
|
and not self.rate_limit_redis_url.strip()
|
||||||
):
|
):
|
||||||
self.rate_limit_redis_url = self.rq_redis_url
|
fallback_url = self.rq_redis_url.strip()
|
||||||
|
if not fallback_url:
|
||||||
|
raise ValueError(
|
||||||
|
"RATE_LIMIT_REDIS_URL or RQ_REDIS_URL must be set and non-empty "
|
||||||
|
"when RATE_LIMIT_BACKEND=redis.",
|
||||||
|
)
|
||||||
|
self.rate_limit_redis_url = fallback_url
|
||||||
|
|
||||||
# In dev, default to applying Alembic migrations at startup to avoid
|
# In dev, default to applying Alembic migrations at startup to avoid
|
||||||
# schema drift (e.g. missing newly-added columns).
|
# schema drift (e.g. missing newly-added columns).
|
||||||
|
|||||||
Reference in New Issue
Block a user