{{ message }}
Repository navigation
fix(cli): render error text literally instead of as Rich markup - #899
Open
farzamfallahi wants to merge 1 commit into
Open
farzamfallahi wants to merge 1 commit into
farzamfallahi wants to merge 1 commit into
Conversation
CLI error lines interpolated exception text into Rich markup strings, so bracketed text such as skills[old]/demo lost its brackets, nope[/x] raised MarkupError, and the MCP install hint dropped [mcp]. Build the error line from a Rich Text object and pass each line through the shared visible_terminal_text helper, matching the approach in NVIDIA#725 and NVIDIA#734. Closes NVIDIA#885. Signed-off-by: Farzam Fallahy <61787362+farzamfallahi@users.noreply.github.com>
Author
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.

Closes #885.
Problem
cli.pyprinted exception text witherr_console.print(f"[red]Error:[/red] {e}"), so any square brackets in the message were parsed as Rich markup:skillspector scan "skills[old]/demo"reportedCannot determine input type for: skills/demo(the[old]was swallowed).skillspector scan "nope[/x]"crashed withMarkupErrorand exit code 1 instead of the usual exit code 2.skillspector mcpwithout the extra printedpip install 'skillspector', dropping[mcp]from the install hint.#725 and #734 fixed the same class of bug for terminal reports and batch output; the CLI error lines were not covered.
Change
Add
_error_line()incli.py. It builds the line from arich.text.Textobject and passes each line of the message through the sharedvisible_terminal_texthelper (already imported as_visible_terminal_text), following the approach reviewed in #725 and #734:Textobject is not markup-escaped)Twelve call sites that interpolated an exception message now use
err_console.print(_error_line(...))(line numbers onmain): 397, 702, 753, 766, 773, 828, 834, 924, 930, 3419 (theskillspector mcphandler), 3523 and 3529.I left alone the
Error:lines that are fixed string literals (nothing to inject), and the recursive child-scan message, which prints a constant with a custom indent.Tests
13 new tests in
tests/unit/test_cli.py:_error_linerendered literally: plain text,skills[old]/demo,nope[/x],[bold]x[/bold], theskillspector[mcp]hint, an emoji shortcode, a trailing backslash, a multi-line message, and an ESC sequence (9 cases)_error_linesurvivesConsole.print(1)skillspector scanonskills[old]/demoandnope[/x]throughCliRunner: exit code 2, bracketed text intact, noMarkupError(2)skillspector mcpwith the extra missing keepsskillspector[mcp]in the hint (1)On the unmodified code, the 10
_error_linetests fail because the helper does not exist; the three end-to-end tests fail for the bug itself:scantests fail with the lost[old]and theMarkupError/ exit 1pip install 'skillspector'printed instead ofskillspector[mcp]make lintandmake format-checkpass.tests/unit/test_cli.pyon its own, with all 13 new tests: 427 passed.Full unit suite (
make test-unit, run before the MCP-hint test was added): 14,739 passed, 6 failed, 35 skipped, 4 xfailed. All 6 failures aretest_native_claude_55_accepts_default_temperature_in_request_and_provenanceintests/unit/test_anthropic_provider.py(KeyError: 'temperature'). They fail identically with my change stashed, so they are unrelated.Behaviour notes
\x09and a carriage return as\x0d(same helper as the terminal report).Textobject rather than a plain string. This is cosmetic.I did not touch
CHANGELOG.md; happy to add a line if you want one.