From 0414aedce57a86d5584c7dbff92eb4905425c571 Mon Sep 17 00:00:00 2001 From: Mgeeeek Date: Thu, 14 May 2026 04:03:35 +0530 Subject: [PATCH] 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. --- cli/python/src/mem0_cli/branding.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/python/src/mem0_cli/branding.py b/cli/python/src/mem0_cli/branding.py index 7879ec8bf..1e36dfd58 100644 --- a/cli/python/src/mem0_cli/branding.py +++ b/cli/python/src/mem0_cli/branding.py @@ -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: