Skip to content

fix(integrations): exit cleanly on unbalanced quote in --integration-options (#3457)#3466

Merged
mnriem merged 2 commits into
github:mainfrom
Noor-ul-ain001:fix/3457-integration-options-unbalanced-quote
Jul 13, 2026
Merged

fix(integrations): exit cleanly on unbalanced quote in --integration-options (#3457)#3466
mnriem merged 2 commits into
github:mainfrom
Noor-ul-ain001:fix/3457-integration-options-unbalanced-quote

Conversation

@Noor-ul-ain001

Copy link
Copy Markdown
Contributor

Summary

Closes #3457. _parse_integration_options in src/specify_cli/integrations/_helpers.py called shlex.split(raw_options) unguarded. An unbalanced quote in the flag value made shlex raise ValueError: No closing quotation, so a raw traceback escaped instead of the clean typer.Exit(1) error every other bad-input path in this function produces (unknown option, missing value, unexpected value all print a message and exit 1).

Reachable from specify init --integration-options=... and every specify integration install/switch/upgrade/migrate --integration-options=....

Before:

$ specify integration install generic --integration-options='--commands-dir "foo'
ValueError: No closing quotation   # raw traceback

After:

$ specify integration install generic --integration-options='--commands-dir "foo'
Error: Could not parse integration options: No closing quotation.
# exit 1

Changes

  • Wrap shlex.split(raw_options) in try/except ValueError, printing a one-line error and raising typer.Exit(1) — matching the loud-fail UX of the sibling bad-input branches in the same function.

Testing

  • Added test_unbalanced_quote_exits_cleanly under TestParseIntegrationOptionsEqualsForm: asserts the unbalanced-quote input raises typer.Exit with exit code 1.
  • Test-the-test: confirmed the new test fails without the source change (raw ValueError propagates).
  • End-to-end via CliRunner on the full integration install ... --integration-options path: exit code 1, clean message, no traceback.
  • pytest tests/integrations/test_integration_subcommand.py → 108 passed, 7 skipped.

🤖 Generated with Claude Code

…options (github#3457)

`_parse_integration_options` called `shlex.split(raw_options)` unguarded, so an
unbalanced quote in the flag value (e.g. `--integration-options='--commands-dir
"foo'`) made shlex raise `ValueError: No closing quotation` and a raw traceback
escaped — unlike every other bad-input path in this function (unknown option,
missing value, unexpected value), which print a message and exit 1.

Reachable from `specify init --integration-options=...` and every `specify
integration install/switch/upgrade/migrate --integration-options=...`.

Wrap the split in a try/except ValueError that prints a one-line error and
raises `typer.Exit(1)`, matching the existing loud-fail UX. Add a test asserting
the unbalanced-quote input raises `typer.Exit` with exit code 1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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 malformed --integration-options without exposing a raw traceback.

Changes:

  • Converts shlex.split failures into a clean exit code 1.
  • Adds regression coverage for unbalanced quotes.
Show a summary per file
File Description
src/specify_cli/integrations/_helpers.py Handles option tokenization errors cleanly.
tests/integrations/test_integration_subcommand.py Adds an unbalanced-quote regression test.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread tests/integrations/test_integration_subcommand.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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: Medium

@mnriem mnriem merged commit c05a626 into github:main Jul 13, 2026
12 checks passed
@mnriem

mnriem commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

davidebibm pushed a commit to davidebibm/spec-kit that referenced this pull request Jul 14, 2026
…options (github#3457) (github#3466)

* fix(integrations): exit cleanly on unbalanced quote in --integration-options (github#3457)

`_parse_integration_options` called `shlex.split(raw_options)` unguarded, so an
unbalanced quote in the flag value (e.g. `--integration-options='--commands-dir
"foo'`) made shlex raise `ValueError: No closing quotation` and a raw traceback
escaped — unlike every other bad-input path in this function (unknown option,
missing value, unexpected value), which print a message and exit 1.

Reachable from `specify init --integration-options=...` and every `specify
integration install/switch/upgrade/migrate --integration-options=...`.

Wrap the split in a try/except ValueError that prints a one-line error and
raises `typer.Exit(1)`, matching the existing loud-fail UX. Add a test asserting
the unbalanced-quote input raises `typer.Exit` with exit code 1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

--integration-options with an unbalanced quote crashes with a raw ValueError

3 participants