Skip to content

fix(core): escape Telegram HTML output (#72)#75

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-a94f
Draft

fix(core): escape Telegram HTML output (#72)#75
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-a94f

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 1, 2026

πŸ“ Description

What: Escape raw HTML control characters in LLM explain output before applying the supported Telegram HTML formatting tags.

Why: Gemini multimodal/text explanations can contain normal comparison text like x < y or raw snippets like <script>, which Telegram rejects when sent with parse_mode=HTML. In the SQS explain path that failure re-raises, causing retries and repeated failed processing or duplicate replies.

Verification:

  • PYTHONPATH=src/bot python3 - <<'PY' ... sanitizer sanity checks passed
  • python3 -m py_compile src/bot/services/ai/telegram_html.py tests/test_telegram_html.py
  • uv run pytest tests/test_telegram_html.py tests/test_explain_multimodal.py could not run: uv is not installed
  • python3 -m pytest tests/test_telegram_html.py tests/test_explain_multimodal.py could not run: pytest is not installed

πŸš€ Type of Change

  • πŸ› Bug Fix (Fix an issue)
  • ✨ New Feature (Add a new feature)
  • πŸ—οΈ Infrastructure (CDK/AWS resource changes)
  • ♻️ Refactoring (Code refactoring, no logic changes)
  • πŸ“š Documentation (Documentation update)

πŸ—οΈ Infrastructure Changes (Crucial)

  • Resources Created: None
  • Resources Modified: None
  • Resources Deleted: None
  • Cost Impact: None

βœ… Checklist

  • I have performed a self-review of my code.
  • I have run pre-commit run --all-files locally and fixed all issues.
  • I have added/updated Unit Tests (pytest).
  • My changes do not generate new warnings.
  • (If Infra change) I have run cdk diff locally to verify changes.

πŸ”— Related Issues

Open in WebΒ View AutomationΒ 

Co-authored-by: Bayashat <baiashat2002@gmail.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.

1 participant