Symptom
Running any DB-touching command without DATABASE_URL exported in the shell (or already in a loaded .env* file) fails with:
Error: Invalid stash.config.ts
- databaseUrl: Invalid input: expected nonoptional, received undefined
The error is misleading — stash.config.ts correctly references process.env.DATABASE_URL. The real problem is that the CLI has no fallback chain when env is empty: no --database-url flag, no Supabase auto-discovery, no interactive prompt.
Affects
stash db install
stash db push
stash db upgrade
stash db status
stash db validate
stash db test-connection
stash schema build
Common ways users specify DB URLs that we don't currently handle
--database-url <url> flag (not implemented).
mise.toml / direnv / shell exports — covered if they populate process.env.DATABASE_URL before the CLI runs, but no graceful failure mode otherwise.
- Local Supabase via
supabase status — not auto-discovered.
- "I have the URL handy, just let me paste it" — no interactive fallback.
Fix
Add a layered resolver that walks: flag → env → supabase status (when the project looks like Supabase) → interactive prompt → fail with a clear source-naming error. Resolved URL is populated into process.env.DATABASE_URL in-process; the stash.config.ts template stays a declarative env reference (no secrets written to disk). The source is logged so users know where the URL came from.
After a prompt-sourced run, the CLI nudges the user to set DATABASE_URL in their existing dotenv file so they don't get re-prompted.
Skipped sources fall through silently (e.g. supabase binary missing). CI=true and non-TTY stdin both skip the prompt and fail fast.
Symptom
Running any DB-touching command without
DATABASE_URLexported in the shell (or already in a loaded.env*file) fails with:The error is misleading —
stash.config.tscorrectly referencesprocess.env.DATABASE_URL. The real problem is that the CLI has no fallback chain when env is empty: no--database-urlflag, no Supabase auto-discovery, no interactive prompt.Affects
stash db installstash db pushstash db upgradestash db statusstash db validatestash db test-connectionstash schema buildCommon ways users specify DB URLs that we don't currently handle
--database-url <url>flag (not implemented).mise.toml/direnv/ shell exports — covered if they populateprocess.env.DATABASE_URLbefore the CLI runs, but no graceful failure mode otherwise.supabase status— not auto-discovered.Fix
Add a layered resolver that walks: flag → env →
supabase status(when the project looks like Supabase) → interactive prompt → fail with a clear source-naming error. Resolved URL is populated intoprocess.env.DATABASE_URLin-process; thestash.config.tstemplate stays a declarative env reference (no secrets written to disk). The source is logged so users know where the URL came from.After a prompt-sourced run, the CLI nudges the user to set
DATABASE_URLin their existing dotenv file so they don't get re-prompted.Skipped sources fall through silently (e.g. supabase binary missing).
CI=trueand non-TTY stdin both skip the prompt and fail fast.