API
The Environment File Copy That Hid a Missing API Key
A deployment mistake and a small startup check that catches missing configuration.
A healthy process still served 500 errors
I copied an old environment file to a new server. The process started and the health endpoint passed, but the first payment test failed because one required key was absent. My shell had the value locally, which made the missing deployment value easy to miss.
Check names, never print secrets
I now make application startup fail when a required value is not present.
required="DATABASE_URL PAYMENT_SECRET SESSION_SECRET"
for key in $required; do
test -n "$(printenv "$key")" || { printf "missing: %s
" "$key"; exit 1; }
done
For systemd, checking a terminal shell is not enough. The service must load the intended file.
[Service]
EnvironmentFile=/etc/myapp/app.env
ExecStart=/usr/bin/node /srv/myapp/server.js
New release checklist
- Keep every key name in
.env.example. - Validate required keys at startup.
- Test one feature that uses each external dependency.
- Do not put values in logs or chat messages.
Copying a file is transport, not verification. A loud startup failure is kinder than a user-visible 500.