Repository navigation
fix: report a non-file .extensionignore or .presetignore as a validation error - #5131
Merged
Merged
Conversation
…ion error load_install_ignore checked exists(), which is also true for a directory, then read_text raised IsADirectoryError and the CLI printed a traceback. Raise the caller's validation error instead, as the docstring already promises for invalid ignore files. Fixes github#5094 Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized guard matches the existing error contract and has regression coverage for both extension and preset callers.
No open issues 🎉
What changed in this PR
Fixes #5094 by making the shared installation-ignore loader report a validation error instead of a traceback when .extensionignore or .presetignore is a directory.
Changes:
- Rejects existing non-file ignore paths using the caller’s validation-error type and updates the docstring.
- Adds regression coverage for both extension and preset callers.
- Preserves missing-file behavior and propagation of other read failures.
Tests were not rerun during this review; the PR reports that both regression cases fail before the fix and pass afterward.
| File | Description |
|---|---|
tests/specify_cli/test_install_ignore.py |
Adds a parameterized directory-path regression test for both callers. |
src/specify_cli/_install_ignore.py |
Adds the regular-file guard and documents the validation behavior. |
Review effort: Max
Collaborator
|
Thank you! |
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.
Description
When an extension or preset source contains a directory named
.extensionignoreor.presetignore,specify extension add --dev(and the preset equivalent) crashes with anIsADirectoryErrortraceback.load_install_ignorechecksexists(), which is also true for a directory, and thenread_textfails.This adds an
is_file()check right after the existence check and raises the caller's validation error (ValidationErrororPresetValidationError), which is what the docstring already promises for invalid ignore files. Nothing is copied. The CLI now printsValidation Error: .extensionignore is not a regular file: <path>and exits 1. A missing ignore file still returns None, and other read failures still propagate as before (test_read_failure_is_propagatedis unchanged).Closes #5094
Testing
uv run specify --helpuv sync && uv run pytestAdded
test_directory_named_like_ignore_file_uses_callers_validation_errortotests/specify_cli/test_install_ignore.py. It runs for both the extension and preset callers through the existingignore_contractfixture. Both cases fail on main withIsADirectoryErrorand pass with this change. The repro script from the issue now ends with the validation error above and nothing is installed.ruff check src testspasses. On macOS, 11 tests in the*_python_parity.pyfiles fail locally both with and without this change, so they are unrelated.AI Disclosure
AI disclosure: AI assistance: Claude Code (Claude Opus 5.5, autonomous agent mode) was used to help write this change, including the code, the test and this description; I reviewed and tested it.