Skip to content

fix: fail loudly on misconfigured DATABASE_URL or REDIS_URL at startup#48

Merged
atkaridarshan04 merged 2 commits into
mainfrom
feat/dockerize
May 22, 2026
Merged

fix: fail loudly on misconfigured DATABASE_URL or REDIS_URL at startup#48
atkaridarshan04 merged 2 commits into
mainfrom
feat/dockerize

Conversation

@atkaridarshan04
Copy link
Copy Markdown
Collaborator

Summary

When DATABASE_URL or REDIS_URL is explicitly set but the service is
unreachable, 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.pyinit_job_store() raises RuntimeError
    instead of falling back to SQLite when DATABASE_URL is set but Postgres
    is unreachable
  • app/adapters/http/app.pylifespan() raises instead of swallowing
    the exception when REDIS_URL is set but Redis is unreachable
  • app/infra/queue/worker.pystartup() logs a clear error before
    re-raising when DATABASE_URL is set but Postgres is unreachable
  • docs/guides/production-deployment.md — documents the new hard-failure
    behaviour for misconfigured URLs

Type

  • Bug fix

Testing

  • pytest passes
  • Coverage ≥ 70%
  • Tested manually (describe below if relevant)

Verified: 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, which
raise on unreachable hosts.

Related Issues

closes #10

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
@atkaridarshan04 atkaridarshan04 requested a review from AK11105 May 21, 2026 12:02
@atkaridarshan04 atkaridarshan04 self-assigned this May 21, 2026
@atkaridarshan04 atkaridarshan04 added the bug Something isn't working label May 21, 2026
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.
@atkaridarshan04 atkaridarshan04 merged commit 628de8a into main May 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail fast on misconfigured DATABASE_URL and REDIS_URL at startup

2 participants