fix: fail loudly on misconfigured DATABASE_URL or REDIS_URL at startup#48
Merged
Conversation
When DATABASE_URL or REDIS_URL is explicitly set but the target service is unreachable, the app now logs a clear ERROR and raises RuntimeError instead of silently falling back to SQLite / in-process async. - deps.init_job_store: raise instead of SQLite fallback when DATABASE_URL set - lifespan: raise instead of pass when REDIS_URL set but Redis unreachable - worker.startup: explicit error log before re-raise for Postgres failure - docs: note hard startup failure on misconfigured URLs
test_falls_back_to_sqlite_when_postgres_unavailable renamed to test_raises_when_database_url_set_but_postgres_unavailable and updated to assert RuntimeError is raised, matching the new hard-failure behaviour.
AK11105
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
DATABASE_URLorREDIS_URLis explicitly set but the service isunreachable, the app now refuses to start with a clear error instead of
silently falling back to SQLite or in-process async.
Changes
app/adapters/http/deps.py—init_job_store()raisesRuntimeErrorinstead of falling back to SQLite when
DATABASE_URLis set but Postgresis unreachable
app/adapters/http/app.py—lifespan()raises instead of swallowingthe exception when
REDIS_URLis set but Redis is unreachableapp/infra/queue/worker.py—startup()logs a clear error beforere-raising when
DATABASE_URLis set but Postgres is unreachabledocs/guides/production-deployment.md— documents the new hard-failurebehaviour for misconfigured URLs
Type
Testing
pytestpassesVerified: unset URLs still fall back to SQLite/in-process as before.
Hard failure path confirmed by reading the error paths — connection
attempt is made by
asyncpg.create_pool/arq.create_pool, whichraise on unreachable hosts.
Related Issues
closes #10