pug icon indicating copy to clipboard operation
pug copied to clipboard

Standardize .env load-error handling in process entry points

Open coderabbitai[bot] opened this issue 3 months ago • 0 comments

Summary

Standardize .env load-error handling in all process entry points that call godotenv.Load().

Required changes

Audit the 18 entry points that use the shared pattern. Continue when .env is absent by checking os.IsNotExist(err). For every other godotenv.Load() error, log the error and terminate with a non-zero exit status.

Do not make this change only in cmd/cron/billing-reconcile/main.go. Keep the entry-point behavior consistent across the sweep.

Rationale

godotenv.Load() can fail because .env is missing, unreadable, or malformed. The current shared pattern treats every failure as a missing .env file. This can start a process with incomplete configuration and produce an incorrect log message.

Affected areas

  • Process entry points that call godotenv.Load().
  • Includes cmd/cron/billing-reconcile/main.go.

Acceptance criteria

  • Each affected entry point ignores only os.IsNotExist(err).
  • Each affected entry point logs and exits non-zero for malformed .env content, permission errors, and other load errors.
  • The handling is consistent across all affected entry points.
  • Tests cover missing-file and malformed-file behavior where the entry-point test setup permits it.

Backlinks

  • Deferred from PR #115: https://github.com/pug-sh/pug/pull/115
  • Review discussion: https://github.com/pug-sh/pug/pull/115#discussion_r3944928066
  • Requested by @poluruprvn.

coderabbitai[bot] avatar Sep 06 '26 19:09 coderabbitai[bot]