fix(events): return None for an unparseable script command - #3957
Open
marcelsafin wants to merge 1 commit into
Open
fix(events): return None for an unparseable script command#3957marcelsafin wants to merge 1 commit into
marcelsafin wants to merge 1 commit into
Conversation
_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>
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents malformed event script commands from crashing dispatch.
Changes:
- Catches
shlex.split()parsing errors and returnsNone. - 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.
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 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 rawValueError: No closing quotation. The dispatcher-template twin a few lines up already wraps the very same call intry/except ValueErrorand returnsNoneso 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
uv run specify --helpuv sync && uv run pytest(6,310 passed, 176 skipped)test_unparseable_script_command_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.