Skip to content

fix: propagate dotenv read errors - #21894

Closed
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:fix/propagate-dotenv-read-errors
Closed

fix: propagate dotenv read errors#21894
OskarEichler wants to merge 1 commit into
webpack:mainfrom
OskarEichler:fix/propagate-dotenv-read-errors

Conversation

@OskarEichler

@OskarEichler OskarEichler commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Dotenv treated every file read failure as a missing optional file, silently swallowing permission errors and other I/O faults. Only ENOENT and ENOTDIR are now recorded as missing dependencies; all other errors reject compilation.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes. Unit regressions cover both expected missing-file codes and EACCES propagation. The focused suite passes 3 tests, and all lint, generated-output, type, format, spelling, changeset, and diff checks pass.

Does this PR introduce a breaking change?

No. Real configuration I/O failures are now reported instead of silently ignored.

If relevant, did you update the documentation?

A patch changeset documents the error-handling correction. No public documentation change is required.

Use of AI

Significant AI assistance was used to audit dotenv loading and draft the fix and regression tests. I reviewed the final diff and verification results.

Summary by CodeRabbit

  • Bug Fixes
    • Improved dotenv file error handling.
    • Missing or invalid paths continue to be handled as absent files.
    • Other read errors are now reported instead of being silently ignored.

@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: afcdcdc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: bce6db07-d0b3-4a0a-91cd-95f63ff2fa47

📥 Commits

Reviewing files that changed from the base of the PR and between 5352fd8 and afcdcdc.

📒 Files selected for processing (3)
  • .changeset/020-dotenv-read-errors.md
  • lib/DotenvPlugin.js
  • test/DotenvPlugin.unittest.js

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The dotenv loader now treats only ENOENT and ENOTDIR as missing files. Other read errors propagate. Unit tests and a patch changeset cover the behavior.

Changes

Dotenv error handling

Layer / File(s) Summary
Handle dotenv read errors
lib/DotenvPlugin.js, .changeset/020-dotenv-read-errors.md
DotenvPlugin preserves missing-dependency handling for ENOENT and ENOTDIR, and rethrows other read errors. The changeset declares a patch release.
Validate error outcomes
test/DotenvPlugin.unittest.js
Tests cover missing files, non-directory paths, and propagation of EACCES.

Merge Risk: ⚪ Minimal · up to afcdc

The change makes unexpected dotenv filesystem errors fail compilation instead of being silently ignored while preserving optional missing-file behavior; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the allowed conventional-commit form fix: subject with an optional scope. It accurately describes the propagation of dotenv read errors.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant

Sponsor
SponsoredKunjungi sekarang
Promo