Skip to content

fix: [issues-245] escape Rich markup in logging to prevent MarkupError crashes#246

Open
miiiak wants to merge 1 commit intoawslabs:mainfrom
miiiak:fix/rich-markup-error-logging
Open

fix: [issues-245] escape Rich markup in logging to prevent MarkupError crashes#246
miiiak wants to merge 1 commit intoawslabs:mainfrom
miiiak:fix/rich-markup-error-logging

Conversation

@miiiak
Copy link
Copy Markdown
Contributor

@miiiak miiiak commented Mar 23, 2026

When model responses or AWS SDK debug logs contain square brackets (e.g. regex patterns like [/\s]), Rich's RichHandler interprets them as markup tags and throws MarkupError, crashing the CLI mid-run.

Proposed fix for #245

Issue #, if available: #245

Description of changes: :

  • Escape record.getMessage() in AgentAwareFormatter using rich_escape()
  • Add _rich_markup_safe flag for app's own styled helper functions
  • Isolate strands/botocore/boto3/urllib3/s3transfer loggers with markup=False handlers and propagate=False

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When model responses or AWS SDK debug logs contain square brackets
(e.g. regex patterns like [/\s]), Rich's RichHandler interprets them
as markup tags and throws MarkupError, crashing the CLI mid-run.

Changes:
- Escape record.getMessage() in AgentAwareFormatter using rich_escape()
- Add _rich_markup_safe flag for app's own styled helper functions
- Isolate strands/botocore/boto3/urllib3/s3transfer loggers with
  markup=False handlers and propagate=False

Fixes awslabs#245
@miiiak miiiak force-pushed the fix/rich-markup-error-logging branch from 57b67a4 to 6e63cef Compare March 23, 2026 19:11
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.

1 participant