From dc25a9df6b585178e5f2781ac8e7a1fc1f724009 Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Wed, 4 Mar 2026 11:56:58 -0700 Subject: [PATCH] fix: fail fast when RATE_LIMIT_BACKEND=redis but no Redis URL is configured Co-Authored-By: Claude Opus 4.6 --- backend/app/core/config.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 6df2be28..a5b7f1f9 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -120,12 +120,19 @@ class Settings(BaseSettings): self.base_url = base_url.rstrip("/") # 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 ( self.rate_limit_backend == RateLimitBackend.REDIS 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 # schema drift (e.g. missing newly-added columns).