fix(cli): escape user-supplied message in print_error
Backend error details can contain `[/...]` or other rich-markup-like text (e.g. regex patterns in validation errors). print_error interpolated the raw string into a markup template, so rich's parser would crash with MarkupError instead of showing the actual error to the user. Escape message + hint via rich.markup.escape so the colored prefix still renders but the user-supplied content prints literally.
This commit is contained in:
@@ -87,10 +87,12 @@ def print_error(console: Console, message: str, hint: str | None = None) -> None
|
||||
}
|
||||
print(_json.dumps(envelope))
|
||||
return
|
||||
from rich.markup import escape
|
||||
|
||||
sym = _sym("✗", "[error]")
|
||||
console.print(f"[{ERROR_COLOR}]{sym} Error:[/] {message}")
|
||||
console.print(f"[{ERROR_COLOR}]{sym} Error:[/] {escape(str(message))}")
|
||||
if hint:
|
||||
console.print(f" [{DIM_COLOR}]{hint}[/]")
|
||||
console.print(f" [{DIM_COLOR}]{escape(str(hint))}[/]")
|
||||
|
||||
|
||||
def print_warning(console: Console, message: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user