fix(obligatron): Only read .env locally#1860
Merged
Conversation
The changes in #1859 is producing runtime errors in PROD: > Uncaught Exception {"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '../../.env'","code":"ENOENT","errno":-2,"syscall":"open","path":"../../.env","stack":["Error: ENOENT: no such file or directory, open '../../.env'"," at loadEnvFile (node:internal/process/per_thread:260:7)"," at Object.<anonymous> (/var/task/index.js:22868:37)"," at Module._compile (node:internal/modules/cjs/loader:1521:14)"," at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)"," at Module.load (node:internal/modules/cjs/loader:1266:32)"," at Module._load (node:internal/modules/cjs/loader:1091:12)"," at Module.require (node:internal/modules/cjs/loader:1289:19)"," at require (node:internal/modules/helpers:182:18)"," at _tryRequireFile (file:///var/runtime/index.mjs:1092:37)"," at _tryRequire (file:///var/runtime/index.mjs:1151:25)"]} The `.env` file holds variables for use locally; this file is not included in production artifacts. This change updates obligatron to read `.env` within `run-locally.ts`. Prior to PR #1859 we were using `dotenv` to read `.env`. It appears that `dotenv` silently continues if a file does not exist, which is why we hadn't seen this issue previously. See https://github.com/motdotla/dotenv/blob/4e5f0e9a08abd5cf0dbcf2c30a68509aa223d371/lib/main.js#L283-L293.
aug24
approved these changes
Mar 13, 2026
Member
Author
|
This has deployed to PROD now. I've manually run the obligatron lambda; the logs show its working as expected again 🎉 :
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What does this change?
The changes in #1859 is producing runtime errors in PROD:
The
.envfile holds variables for use locally; this file is not included in production artifacts. This change updates obligatron to read.envwithinrun-locally.ts.Prior to PR #1859 we were using
dotenvto read.env. It appears thatdotenvsilently continues if a file does not exist, which is why we hadn't seen this issue previously. See https://github.com/motdotla/dotenv/blob/4e5f0e9a08abd5cf0dbcf2c30a68509aa223d371/lib/main.js#L283-L293.How has it been verified?
After deploying to CODE and invoking the lambda, the above issue has been removed from the logs (screenshot below) and the lambda runs successfully.