A missing line in .env.example took down our prod, so I built a PR check for it
说明与用途
缺少 .env.example 中的一行导致生产环境崩溃,作者构建了 deployhealth 工具,自动扫描环境变量使用情况,与 .env.example 比对,并通过 PR 检查、CLI 扫描和正常运行监控报告缺失变量。
问题
A missing environment variable caused a production outage after a deploy, and existing safety nets failed to catch it.
结果
Deployhealth prevents missing env var outages by automating detection and reporting, reducing manual debugging time from hours to seconds.
工作流
- Scan repository for env var usage in code
- Compare found vars against .env.example and .env files
- In PRs, comment on new env var usage and missing declarations
- Flag committed .env files with potential leaked keys
- Run CLI scan on every push to report unused or missing vars
- Monitor uptime to detect failures linked to recent deploys and report introduced missing vars
证据
The cause was an env var. The change read a new variable that existed on the developer's machine but had never been added to .env.example or to production.
Validate env vars at startup. t3-env, envalid or a small zod schema make the app fail on boot with a clear message, instead of on the first request with a mystery 500.
It started as envcheck, a small scanner that finds every env var your code reads and compares them with your env files. Pull request checks and uptime monitoring grew around it, and it became deployhealth.
Acme API started failing 4m after deploy b52952e, which introduced 2 missing env vars: REDIS_URL, STRIPE_KEY
- 记录日期: 2026-10-06T16:41:00.374Z