Skip to content

fix(events): return None for an unparseable script command - #3957

Merged
mnriem merged 1 commit into
github:mainfrom
marcelsafin:fix/event-shlex-valueerror
Aug 4, 2026
Merged

fix(events): return None for an unparseable script command#3957
mnriem merged 1 commit into
github:mainfrom
marcelsafin:fix/event-shlex-valueerror

Conversation

@marcelsafin

Copy link
Copy Markdown
Contributor

Description

The script-command resolver splits the configured command with a bare shlex.split(), so a command string with unbalanced quotes (e.g. command: "run 'oops") crashes event dispatch with a raw ValueError: No closing quotation. The dispatcher-template twin a few lines up already wraps the very same call in try/except ValueError and returns None so dispatch falls back cleanly.

Fix: wrap the split the same way and return None, restoring parity between the two paths. One malformed hook entry no longer takes down dispatch for every other hook.

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_unparseable_script_command_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.

_script_command() split the configured command with a bare
shlex.split(), so a command string with unbalanced quotes crashed event
dispatch with a raw ValueError. The dispatcher-template twin a few
lines up already wraps the same call in try/except ValueError and
returns None so dispatch falls back cleanly.

Wrap the split the same way and return None, restoring parity between
the two paths.

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 3, 2026 19:55
@marcelsafin
marcelsafin requested a review from mnriem as a code owner August 3, 2026 19:55

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

Prevents malformed event script commands from crashing dispatch.

Changes:

  • Catches shlex.split() parsing errors and returns None.
  • Adds regression coverage for unbalanced quotes.

Reviewed changes

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

File Description
src/specify_cli/events.py Gracefully handles unparseable script commands.
tests/integrations/test_events.py Tests malformed command handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem
mnriem requested a balanced review from Copilot August 4, 2026 11:45

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 316cd12 into github:main Aug 4, 2026
14 checks passed
@mnriem

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