fix(extensions): reject reinstall when a kept config cannot be read - #3960
Merged
Conversation
The keep-config rescue branch of install_from_directory() reads each preserved config with bare read_bytes()/stat() calls, so a kept config that cannot be read (permission or I/O error) crashed the reinstall with a raw OSError. The sibling symlink guard four lines above already rejects with a ValidationError and resolution guidance for the same reason: bytes that cannot be safely rescued must not reach the rmtree below. Wrap the read and raise ValidationError with guidance, while dest_dir is still untouched so the preserved bytes are never lost. Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds safe error handling when reinstalling an extension whose preserved configuration cannot be read.
Changes:
- Converts config read/stat failures into actionable
ValidationErrors before deletion. - Adds regression coverage confirming the config remains untouched.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/specify_cli/extensions/__init__.py |
Handles preserved-config read failures safely. |
tests/test_extensions.py |
Tests unreadable preserved-config behavior. |
馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
The keep-config rescue branch of
install_from_directory()reads each preserved config with bareread_bytes()/stat()calls, so a kept config that cannot be read (permission or I/O error) crashes the reinstall with a rawOSError. The sibling symlink guard four lines above already rejects with aValidationErrorand resolution guidance for exactly the same reason: bytes that cannot be safely rescued must never reach thermtreebelow.Fix: wrap the read and raise
ValidationErrorwith guidance (fix its permissions or remove it, then reinstall) whiledest_diris still untouched, so the preserved bytes are never rescued half-read or lost.Testing
uv run specify --helpuv sync && uv run pytest(6,310 passed, 176 skipped)test_reinstall_with_unreadable_kept_config_aborts_with_guidance(fails on main with rawPermissionError, passes with fix)ruff check src testscleanAI Disclosure
Implemented autonomously by GitHub Copilot CLI (model: Claude Fable 5) under human direction; TDD (failing test first), full suite and lint verified locally. Commit includes
Assisted-by/Co-authored-bytrailers.