fix(events): skip an unreadable command template - #3956
Open
marcelsafin wants to merge 2 commits into
Open
Conversation
_render_command_template() read the resolved template with a bare read_text(), so a template file that exists but cannot be read or decoded (permission error, non-UTF-8 bytes) crashed event dispatch with a raw OSError/UnicodeDecodeError. Every sibling failure in this path (missing template, unresolvable command) already returns None so the dispatcher falls back cleanly. Wrap the read and return None on OSError/UnicodeDecodeError, matching the sibling contract. 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
Handles unreadable event command templates without crashing dispatch.
Changes:
- Returns
Nonefor template read/decode failures. - Adds regression coverage for invalid UTF-8 templates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/specify_cli/events.py |
Gracefully handles unreadable templates. |
tests/integrations/test_events.py |
Tests invalid UTF-8 fallback behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review follow-up: add a mocked PermissionError case so both promised exception paths are protected under privileged CI. Assisted-by: GitHub Copilot (model: claude-fable-5, autonomous) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 event command runner reads the resolved command template with a bare
read_text(), so a template file that exists but cannot be read or decoded (permission error, non-UTF-8 bytes) crashes event dispatch with a rawOSError/UnicodeDecodeError. Every sibling failure in this path — missing template, unresolvable command — already returnsNoneso the dispatcher falls back cleanly.Fix: wrap the read and return
Noneon(OSError, UnicodeDecodeError), matching the sibling contract. An unreadable template now behaves exactly like a missing one.Testing
uv run specify --helpuv sync && uv run pytest(6,310 passed, 176 skipped)test_unreadable_template_returns_none(fails on main, 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.