Fix Config.from_file() silent mode not handling ENOTDIR#5913
Closed
veeceey wants to merge 1 commit intopallets:mainfrom
Closed
Fix Config.from_file() silent mode not handling ENOTDIR#5913veeceey wants to merge 1 commit intopallets:mainfrom
veeceey wants to merge 1 commit intopallets:mainfrom
Conversation
`Config.from_file()` with `silent=True` did not handle `errno.ENOTDIR`, causing it to raise an error when a path component is a regular file instead of a directory. This was inconsistent with `Config.from_pyfile()`, which has handled ENOTDIR since PR pallets#2581. fixes pallets#5912 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
You really had to use an LLM for a change this small?! 🙈 |
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.
Summary
Config.from_file()withsilent=TrueraisesNotADirectoryErrorwhen a path component is a regular file rather than a directory (e.g.~/.myapp/config.jsonwhen~/.myappis a regular file). This is inconsistent withConfig.from_pyfile(), which correctly handles this case by returningFalse.errno.ENOTDIRwas added tofrom_pyfilein PR silence ENOTDIR when loading config file #2581 (fixing Treat errno.ENOTDIR like errno.EISDIR when silently absorbing IOErrors in config.from_pyfile (from_json, etc.) #2545) but was never applied tofrom_json(nowfrom_file), even though the original issue title mentioned "from_json, etc."errno.ENOTDIRtofrom_file()'s silent error handling to matchfrom_pyfile().fixes #5912
Test plan
test_config_enotdir_from_file-- verifiesfrom_file(..., silent=True)returnsFalsewhenENOTDIRis encounteredtest_config_enotdir_from_pyfile-- documents the existing correct behavior offrom_pyfilefor the same scenariotest_config_enotdir_from_filefails without the fix (NotADirectoryErroris raised)test_config.pysuite passes (21/21 tests)🤖 Generated with Claude Code