The environment variable that cost me a day
It worked on my machine, failed in production, and the difference was one missing string. Now I fail fast on purpose.
By Nzubechukwu Cyprian · Pharmacy student at UNN, full-stack developer
One day, a feature worked perfectly locally and fell over in production. Same code, same database. The difference: an environment variable that existed in my .env.local and nowhere else. The code read it as undefined, took a default path I'd written for development, and quietly did the wrong thing in front of real users.
The lessons, priced in one lost day
Validate config at startup. The app should refuse to boot when something required is missing — loudly, with the variable's name in the error. Silent defaults for required config are landmines with a delay timer.
Separate required from optional, in code. Optional values can have defaults. Required ones get assertions, not fallbacks.
Document every variable where it's used. A one-line comment above each process.env read: what it is, what happens without it. Future setup-me at midnight will bless present-me.
The general shape of the bug
This is the "worked on my machine" genre, and the root cause is almost always an untested difference between environments. The fix isn't being careful — it's making the environments prove themselves. Startup validation, a config checklist in the README, and deploys that fail fast instead of failing weird.
The bug was never the missing variable. The bug was that absence was allowed to proceed.
Keep reading
- Software engineering
Naming things is the whole job, sometimes
Most codebases don't have a naming problem — they have a thinking problem that shows up in their identifiers.
- Software engineering
Your README is your first interview
Before anyone judges your code, they judge your README. What a good one actually contains, from someone who reads a lot of them.
- Software engineering
The bug that taught me to read error messages properly
A three-line error sat in my logs for a week. It told me exactly what was wrong. I just never read past the first line.