buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(admin): fail loudly when DATABASE_URL is unset instead of falling back to dev credentials

Open JoeJoeflyn opened this issue 4 months ago • 0 comments

Summary

  • replace unwrap_or_else(|_| "postgres://buzz:buzz_dev@localhost:5432/buzz") in connect_db() with std::env::var("DATABASE_URL").context(...)?
  • add Context to the anyhow import
  • add regression test spawning buzz-admin migrate with DATABASE_URL unset

Why

buzz-admin silently substituted hardcoded dev credentials when DATABASE_URL was missing, masking a missing-config problem as a misleading password authentication failed for user "buzz" error on deployments with hardened credentials. Failing loudly surfaces the real problem and points the operator at .env.

The relay doesn't load .env internally either — both binaries rely on just's set dotenv-load := true. Failing hard makes buzz-admin consistent with the relay's behavior (no silent fallback) rather than introducing a new inconsistency.

Test plan

  • cargo fmt -p buzz-admin -- --check
  • cargo test -p buzz-admin --test db_url_unset (1 passed)
  • cargo clippy -p buzz-admin --all-targets -- -D warnings
  • git diff --check

Closes #2837

JoeJoeflyn avatar Jul 25 '26 12:07 JoeJoeflyn