Skip to content

fix: don't print a stderr warning when .env simply doesn't exist - #181

Merged
Tgenz1213 merged 3 commits into
mainfrom
worktree-issue-178-dotenv-warning
Sep 16, 2026
Merged

Tgenz1213 merged 3 commits into
mainfrom
worktree-issue-178-dotenv-warning

Conversation

@Tgenz1213

Copy link
Copy Markdown
Owner

Summary

  • internal/cli.Execute no longer prints failed to load .env: open .env: no such file or directory on every run when there's simply no .env file (the common case for shell-env and CI-secret setups).
  • A .env file that exists but fails to parse still produces the same clear warning on stderr.

Changes

  • internal/cli/cli.go: only report godotenv.Load()'s error when it's not an os.IsNotExist error.
  • internal/cli/cli_test.go: added TestExecute_MissingDotEnv_NoStderrWarning and TestExecute_MalformedDotEnv_PrintsStderrWarning, covering both cases end-to-end through Execute.

Testing

  • go build ./..., go vet ./..., and go test ./... all pass.
  • golangci-lint run panics in this local environment on both main and this branch (pre-existing Go 1.27 vs. golangci-lint toolchain incompatibility, confirmed unrelated to this change) — CI's pinned toolchain should be unaffected, but flagging in case it needs a separate look.
  • gofmt is clean on the touched files (once CRLF is stripped, which is a known false-positive on this Windows checkout, per repo convention).

Closes #178

🤖 Generated with Claude Code

godotenv.Load() returns an error whenever .env is absent, which is the
normal case for setups that use shell env vars or CI secrets instead of
a checked-in .env file. Only warn when .env exists but fails to parse.

Closes #178

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 03:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The missing .env test should assert that stderr is exactly empty.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Suppresses warnings for missing .env files while retaining malformed-file diagnostics.

Changes:

  • Ignore os.IsNotExist errors from godotenv.Load.
  • Add end-to-end tests for missing and malformed .env files.
File summaries
File Description
internal/cli/cli.go Filters expected missing-file errors.
internal/cli/cli_test.go Covers missing and malformed .env behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/cli/cli_test.go Outdated
Tgenz1213 and others added 2 commits September 15, 2026 22:40
Per Copilot review on #181: a stricter empty-stderr check is more
precise than substring-checking for ".env", since the code path under
test doesn't write anything else to stderr.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…tenv-warning

# Conflicts:
#	internal/cli/cli_test.go
@Tgenz1213
Tgenz1213 merged commit 7d75feb into main Sep 16, 2026
7 checks passed
@Tgenz1213
Tgenz1213 deleted the worktree-issue-178-dotenv-warning branch September 16, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: don't print a stderr error when .env simply doesn't exist

2 participants