Catching Missing .env Variables and Config Drift Before Production Deploys
Adding a key to a local .env file without mirroring it in .env.example or the deployment environment can go unnoticed until production fails with a KeyError or empty value. Stale variables also build up in templates, making required settings hard for new developers to identify. The article proposes treating configuration drift as a build failure instead of a passive warning. It introduces the zero-dependency envdoctor-cli tool, which compares .env against .env.example, exits non-zero on mismatches, and can add masked placeholders for missing keys. An AST-based audit of os.getenv and os.environ calls is also recommended to catch undocumented variables, and running these checks in CI on each pull request is advised.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in