Skip to content

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

Open
Noor-ul-ain001 wants to merge 1 commit into
github:mainfrom
Noor-ul-ain001:fix/3457-integration-options-unbalanced-quote
Open

fix(integrations): exit cleanly on unbalanced quote in --integration-options (#3457)#3466
Noor-ul-ain001 wants to merge 1 commit 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>
@Noor-ul-ain001 Noor-ul-ain001 requested a review from mnriem as a code owner July 11, 2026 05:18
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

1 participant