Repository navigation
Description
Summary
Three backend services keep a legacy unauthenticated redis://redis:6379 fallback in their os.getenv calls — outside the diff of PR #643 but breaking the single-source-of-truth principle that PR establishes (config.py raises if REDIS_URL lacks credentials, but these modules use os.getenv directly and skip that fail-fast guard).
Affected files
src/backend/services/slot_service.py:402
redis_url = os.getenv("REDIS_URL", "redis://redis:6379")
src/backend/services/ssh_service.py:549
redis_url = os.getenv("REDIS_URL", "redis://redis:6379")
src/backend/services/capacity_manager.py:162
url = redis_url or os.getenv("REDIS_URL", "redis://redis:6379")
(ssh_service.py:43 may have a second occurrence — sweep the repo when fixing.)
Why this matters
In production these branches aren't hit because docker-compose always sets REDIS_URL with creds. But:
-
Test/CI paths that import these modules without first importing
src/backend/config.pyskip the fail-fast guard — they silently fall back to unauth localhost, then hitNOAUTHat runtime instead of a clear "REDIS_URL must include credentials" message at startup. -
A future operator running these services outside the docker stack (debug shell, one-off script) gets a confusing connection error rather than the actionable error SEC: Redis has no requirepass — agent containers have unauthenticated full read/write access to platform task queue (AISEC-C1) #589 establishes.
-
Single source of truth violated —
config.pyis the canonical Redis URL gate;os.getenv("REDIS_URL", "...")scattered across services means any new service can introduce a fresh fallback without fail-fast coverage.
Recommended fix
Replace each os.getenv("REDIS_URL", "redis://redis:6379") with an import from config:
from config import REDIS_URL
# ... use REDIS_URL directlyFor capacity_manager.py:162 (which accepts an explicit redis_url parameter):
from config import REDIS_URL as _DEFAULT_REDIS_URL
url = redis_url or _DEFAULT_REDIS_URLAfter the sweep, grep should return zero matches:
grep -rn 'os\.getenv.*REDIS_URL\|getenv("REDIS_URL"' src/backend/services/
# expected: emptyAcceptance criteria
- All three services import
REDIS_URLfromconfiginstead of usingos.getenvfallback - No remaining
redis://redis:6379literal anywhere undersrc/backend/services/ - Existing tests still pass (these are unit-level imports; should be safe)
- Add a unit test that asserts no
os.getenv("REDIS_URL"pattern exists insrc/backend/services/(lint-style guard against regression)
Out of scope
src/scheduler/config.py:14— already usesos.getenv("REDIS_URL", "")correctly with fail-fastsrc/backend/config.py:32— same, this is the canonical gate
Related
- PR fix(security): lock down Redis — auth + ACL + network split (#589) #643 — Redis lock-down (which this completes)
- Issue SEC: Redis has no requirepass — agent containers have unauthenticated full read/write access to platform task queue (AISEC-C1) #589 — Redis auth (parent issue)
Activity
refactor(config): remove legacy unauth REDIS_URL fallbacks (#645) (#697)
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
Release: v0.6.1 (#1171)
fix(skills): resolve REDIS_URL through config, not os.getenv (#645 gu…