Bug description
gcop commit (and any command that prints via Logger.color_info) crashes with a Rich MarkupError when the staged diff contains bracketed text that looks like Rich markup.
MarkupError: closing tag '[/?#]' at position 57492 doesn't match any open tag
Reproduction
- Stage a file containing a JavaScript regex character class such as
url.split(/[/?#]/) — common in minified bundles (e.g. utils.bundle.js).
- Run
gcop commit (or git c).
- The command crashes before generating a commit message.
Minimal repro of the underlying call:
from gcop.utils.logger import logger, Color
logger.color_info("[Code diff] \nurl.split(/[/?#]/)[0]", color=Color.YELLOW)
# rich.errors.MarkupError: closing tag '[/?#]' ... doesn't match any open tag
Root cause
Logger.color_info in gcop/utils/logger.py prints untrusted content (git diffs, AI-generated messages, git command output) through rich.console.Console.print with markup parsing enabled, and additionally wraps the message in its own [color]...[/] tags:
formatted_msg = (
f"[{color.value}]{message}[/]" if color != Color.DEFAULT else message
)
self.console.print(formatted_msg, style=color.value)
Any [...] sequence in the diff is parsed as a Rich tag. A sequence starting with [/ is treated as a closing tag and raises MarkupError. This also silently swallows literal labels like [Thought] and [Code diff] as unknown tags.
Suggested fix
Print with markup=False and rely on the style parameter for color (the manual markup tag wrapping is redundant):
self.info(message, *args, **kwargs)
self.console.print(message, style=color.value, markup=False)
This fixes the crash for all color_info call sites at once (diff echo, AI thought/commit message output, gcop info output, error messages) and makes bracketed labels display literally.
I have a fix ready and will submit a PR shortly.
Bug description
gcop commit(and any command that prints viaLogger.color_info) crashes with a RichMarkupErrorwhen the staged diff contains bracketed text that looks like Rich markup.Reproduction
url.split(/[/?#]/)— common in minified bundles (e.g.utils.bundle.js).gcop commit(orgit c).Minimal repro of the underlying call:
Root cause
Logger.color_infoingcop/utils/logger.pyprints untrusted content (git diffs, AI-generated messages, git command output) throughrich.console.Console.printwith markup parsing enabled, and additionally wraps the message in its own[color]...[/]tags:Any
[...]sequence in the diff is parsed as a Rich tag. A sequence starting with[/is treated as a closing tag and raisesMarkupError. This also silently swallows literal labels like[Thought]and[Code diff]as unknown tags.Suggested fix
Print with
markup=Falseand rely on thestyleparameter for color (the manual markup tag wrapping is redundant):This fixes the crash for all
color_infocall sites at once (diff echo, AI thought/commit message output,gcop infooutput, error messages) and makes bracketed labels display literally.I have a fix ready and will submit a PR shortly.