Skip to content

fix: report a non-file .extensionignore or .presetignore as a validation error - #5131

Merged
mnriem merged 1 commit into
github:mainfrom
costajohnt:fix/5094-install-ignore-directory
Oct 26, 2026
Merged

mnriem merged 1 commit into
github:mainfrom
costajohnt:fix/5094-install-ignore-directory

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

Description

When an extension or preset source contains a directory named .extensionignore or .presetignore, specify extension add --dev (and the preset equivalent) crashes with an IsADirectoryError traceback. load_install_ignore checks exists(), which is also true for a directory, and then read_text fails.

This adds an is_file() check right after the existence check and raises the caller's validation error (ValidationError or PresetValidationError), which is what the docstring already promises for invalid ignore files. Nothing is copied. The CLI now prints Validation 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_propagated is unchanged).

Closes #5094

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

Added test_directory_named_like_ignore_file_uses_callers_validation_error to tests/specify_cli/test_install_ignore.py. It runs for both the extension and preset callers through the existing ignore_contract fixture. Both cases fail on main with IsADirectoryError and pass with this change. The repro script from the issue now ends with the validation error above and nothing is installed. ruff check src tests passes. On macOS, 11 tests in the *_python_parity.py files fail locally both with and without this change, so they are unrelated.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

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.

…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)
@costajohnt
costajohnt requested a review from mnriem as a code owner October 26, 2026 17:18
@mnriem mnriem added the triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate label Oct 26, 2026
@mnriem
mnriem requested a max review from Copilot October 26, 2026 20:31

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.

🟢 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

@mnriem
mnriem merged commit 3b76e6e into github:main Oct 26, 2026
16 checks passed
@mnriem

mnriem commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: specify extension add --dev shows a traceback when .extensionignore is a directory

3 participants