Skip to content

fix(events): skip an unreadable command template - #3956

Merged
mnriem merged 2 commits into
github:mainfrom
marcelsafin:fix/event-template-read
Aug 7, 2026
Merged

fix(events): skip an unreadable command template#3956
mnriem merged 2 commits into
github:mainfrom
marcelsafin:fix/event-template-read

Conversation

@marcelsafin

Copy link
Copy Markdown
Contributor

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 raw OSError/UnicodeDecodeError. Every sibling failure in this path — missing template, unresolvable command — already returns None so the dispatcher falls back cleanly.

Fix: wrap the read and return None on (OSError, UnicodeDecodeError), matching the sibling contract. An unreadable template now behaves exactly like a missing one.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest (6,310 passed, 176 skipped)
  • New regression test test_unreadable_template_returns_none (fails on main, passes with fix)
  • ruff check src tests clean

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

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-by trailers.

Copilot AI balanced review requested due to automatic review settings August 3, 2026 19:54
@marcelsafin
marcelsafin requested a review from mnriem as a code owner August 3, 2026 19:54

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.

Pull request overview

Handles unreadable event command templates without crashing dispatch.

Changes:

  • Returns None for 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.

Comment thread tests/integrations/test_events.py
Copilot AI review requested due to automatic review settings August 3, 2026 20:13

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

marcelsafin and others added 2 commits August 5, 2026 09:55
_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>
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>
Copilot AI review requested due to automatic review settings August 5, 2026 08:11
@marcelsafin
marcelsafin force-pushed the fix/event-template-read branch from daef8f1 to 72c06d8 Compare August 5, 2026 08:11

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mnriem
mnriem requested a balanced review from Copilot August 7, 2026 17:04

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@mnriem
mnriem merged commit 5d9ac6a into github:main Aug 7, 2026
14 checks passed
@mnriem

mnriem commented Aug 7, 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants