Skip to content

.86217969640660:06c6a084a8bfc89a4056d4e11182afef_69859519996d44662aa1452a.69859581996d44662aa145ac.69859581e025b4dd455ac9c6:Trae CN.T(2026/2/6 15:17:21)#372

Open
xzccreat wants to merge 2 commits intobytedance:mainfrom
xzccreat:main
Open

Conversation

@xzccreat
Copy link
Copy Markdown

@xzccreat xzccreat commented Feb 6, 2026

Fix Rich MarkupError in CLI Error Handling

Problem

The Trae Agent CLI was crashing with rich.errors.MarkupError when exception messages contained special characters like square brackets ([, ]). This occurred because rich was trying to parse these characters as markup tags when printing error messages.

Root Cause

In trae_agent/cli.py, error messages were being printed using:

error_text = Text(f"Error: {e}", style="red")
console.print(f"\n{error_text}")  # Could fail with MarkupError

When exception e contained brackets, rich would try to parse them as markup, causing crashes like:

  • MarkupError: closing tag '[/section]' doesn't match any open tag

Solution

Added markup=False parameter to console.print() calls when printing Text objects containing exception messages:

error_text = Text(f"Error: {e}", style="red")
console.print(error_text, markup=False)  # Prevents MarkupError

Changes Made

  • File: trae_agent/cli.py
  • Lines fixed: 4 locations where console.print(error_text) was called
  • Impact: Minimal code change, no behavioral change, improved stability

Testing

  • Created comprehensive test scripts that verify the fix works
  • Tested with various problematic strings containing brackets
  • Confirmed error messages still display with red styling as intended
  • Verified CLI no longer crashes on exception messages with special characters

Verification

Run the provided test scripts:

python test_markup_fix.py
python demonstrate_markup_fix.py

Both should complete without errors, proving the fix is working correctly.

Backward Compatibility

  • ✅ No API changes
  • ✅ No user-facing behavioral changes
  • ✅ Error messages maintain original styling
  • ✅ Only prevents crashes, doesn't change functionality

This fix ensures the CLI remains stable when handling exceptions with special characters in their messages.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@xzccreat xzccreat changed the title 86217969640660:06c6a084a8bfc89a4056d4e11182afef_69859519996d44662aa1452a.69859581996d44662aa145ac.69859581e025b4dd455ac9c6 .86217969640660:06c6a084a8bfc89a4056d4e11182afef_69859519996d44662aa1452a.69859581996d44662aa145ac.69859581e025b4dd455ac9c6:Trae CN.T(2026/2/6 15:17:21) Feb 6, 2026
maharab549 pushed a commit to maharab549/trae-agent that referenced this pull request Mar 1, 2026
* feat: add i18n support and add Chinese

* fix: resolve conflicts

* Update en.json with cancle settings

* Update zh.json with settngs cancle

---------

Co-authored-by: johnny0120 <15564476+johnny0120@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants