hermes - 💡(How to fix) Fix [Bug] extract_media: Markdown bold ** in MEDIA paths causes file-not-found on all platforms

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

The extract_media() function in gateway/platforms/base.py uses a regex that captures the path group, but the subsequent rstrip() does NOT strip trailing asterisks (*). This causes the literal ** characters to remain in the extracted path, resulting in a file-not-found error. 5. Send fails with error: Media file not found: /临时/报告.docx**

Root Cause

File: gateway/platforms/base.py Line: ~2020

Current code:

path = path.lstrip("`\"'").rstrip("`\"',.;:)}")

The rstrip character set does not include *, so when the LLM outputs **MEDIA:/path/to/file.docx**, the captured path becomes /path/to/file.docx** — a non-existent file.

Fix Action

Fix / Workaround

  • Severity: Medium — prevents file delivery on all platform adapters
  • Frequency: Any time the LLM uses bold syntax around a MEDIA path
  • Workaround: Manually edit base.py after each Hermes update to add * to rstrip

Code Example

path = path.lstrip("`\"'").rstrip("`\"',.;:)}")

---

path = path.lstrip("`\"'").rstrip("`\"',.;:)}*")
RAW_BUFFERClick to expand / collapse

Bug Description

When an agent generates a file (e.g. a .docx report) and the LLM responds to the user, it often wraps the file path in Markdown bold syntax: **MEDIA:/path/to/file.docx**.

The extract_media() function in gateway/platforms/base.py uses a regex that captures the path group, but the subsequent rstrip() does NOT strip trailing asterisks (*). This causes the literal ** characters to remain in the extracted path, resulting in a file-not-found error.

Root Cause

File: gateway/platforms/base.py Line: ~2020

Current code:

path = path.lstrip("`\"'").rstrip("`\"',.;:)}")

The rstrip character set does not include *, so when the LLM outputs **MEDIA:/path/to/file.docx**, the captured path becomes /path/to/file.docx** — a non-existent file.

Reproduction

  1. Use any platform that inherits BasePlatformAdapter.extract_media() (QQ, WeChat, Telegram, etc.)
  2. Have a Skill generate a document file (e.g. .docx, .xlsx)
  3. The LLM responds with **MEDIA:/临时/报告.docx** (Markdown bold wrapping the path)
  4. The extracted path becomes /临时/报告.docx** — file not found
  5. Send fails with error: Media file not found: /临时/报告.docx**

Affected Platforms

All platforms that use BasePlatformAdapter.extract_media():

  • QQ (qqbot)
  • WeChat (weixin)
  • Telegram
  • And likely all other platform adapters

Why This Happens

The PLATFORM_HINTS for QQ/WeChat platforms encourage Markdown formatting:

"QQ supports markdown formatting and emoji"

This leads LLMs (especially Chinese-language models) to naturally bold paths using **...**. The extract_media() regex correctly identifies MEDIA:/path/file.docx but the trailing ** from the bold syntax leaks into the path group because rstrip does not strip *.

Suggested Fix

Add * to the rstrip character set in base.py line ~2020:

path = path.lstrip("`\"'").rstrip("`\"',.;:)}*")

This is a one-character change with minimal risk — * is extremely rare in valid file paths.

Impact

  • Severity: Medium — prevents file delivery on all platform adapters
  • Frequency: Any time the LLM uses bold syntax around a MEDIA path
  • Workaround: Manually edit base.py after each Hermes update to add * to rstrip

Related Issues

  • #21527 — Telegram media path escaping broken (similar regex issue)
  • #1803 — MEDIA: tag fails to send files
  • #22492 — qqbot: add extensions to extract_media() regex

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug] extract_media: Markdown bold ** in MEDIA paths causes file-not-found on all platforms