fix(integrations): exit cleanly on malformed --integration-options quoting
fixes #3457
_parse_integration_options called shlex.split(raw_options) unguarded. an unbalanced quote in the flag value (e.g. --integration-options='--commands-dir "foo') makes shlex raise ValueError: No closing quotation, so a raw traceback escaped instead of the typer.Exit(1) error every other bad-input path in this function produces (unknown option, missing value, unexpected value). reachable from specify init and every integration install/switch/upgrade/migrate that accepts --integration-options.
fix: wrap the shlex.split in try/except and convert ValueError into the same clean one-line CLI error + exit 1.
added a regression test (test_malformed_quoting_exits_cleanly) asserting a typer.Exit on an unbalanced quote. i confirmed it fails on the pre-fix code by stashing the source and re-running (raw ValueError: No closing quotation); the parse-options tests pass with the fix.
note: i used an ai assistant to help investigate and write this up.
escaped the value before interpolating it in aa810ba — you're right that --commands-dir "[/red]foo tripped the intended ValueError but then the error print itself raised MarkupError on the unbalanced tag and leaked a traceback anyway.
swept the two sibling branches in the same function too (the 'unexpected option value' and 'unknown option' prints both interpolate the raw token), since a bare [/red]foo token would hit the same wall without an unbalanced quote.
regression covers both: an unbalanced-quote value carrying markup, and a plain markup token. confirmed both raise MarkupError on the pre-fix code and exit cleanly with the escape.
Please resolve conflicts
Please address Copilot feedback
Addressed the Copilot feedback. The flagged test (test_malformed_quoting_with_rich_markup_exits_cleanly) had an inaccurate docstring — the shlex failure branch prints only {exc}, which never carries the caller's markup, so that path was already clean via the existing test_unbalanced_quote_exits_cleanly. Its [/red]foo assertion also duplicated test_bad_option_token_with_rich_markup_exits_cleanly. Removed the redundant test; the substantive change remains escaping the two user-controlled token prints (the unexpected-value and unknown-option branches) so an unbalanced Rich tag exits cleanly instead of raising MarkupError.
Updated the PR title and description to match the actual scope. You're right that the shlex.split ValueError conversion for #3457 is already on main and unchanged in this diff — the only production behavior here is escaping the two user-controlled token prints (unexpected-value and unknown-option branches) so an unbalanced Rich tag exits cleanly instead of raising MarkupError. The title now says "escape Rich markup in --integration-options error messages" and the body frames this as follow-up hardening to the already-fixed #3457 rather than re-adding that fix.
Thank you!