hermes - 💡(How to fix) Fix [Bug]: MEDIA file not found sends message to main room instead of thread [1 pull requests]

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

Operating System

Ubuntu 24.04

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause

When sending a MEDIA file that does not exist, _send_local_file() sends an error message (file not found: /path) to the main room instead of the intended thread. This happens because the error message bypasses thread routing — metadata (containing thread_id) is not properly handled.

Fix Action

Fixed

Code Example

if not p.exists():
    return await self.send(
        room_id, f"{caption or ''}\n(file not found: {file_path})", reply_to,
        metadata=metadata
    )

---

if not p.exists():
    logger.warning("Matrix: MEDIA file not found, skipping: %s", file_path)
    return SendResult(success=False, error=f"file not found: {file_path}")

---

### Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

### Messaging Platform (if gateway-related)

_No response_

### Debug Report

---

### Operating System

Ubuntu 24.04

### Python Version

_No response_

### Hermes Version

_No response_

### Additional Logs / Traceback (optional)
RAW_BUFFERClick to expand / collapse

Bug Description

When sending a MEDIA file that does not exist, _send_local_file() sends an error message (file not found: /path) to the main room instead of the intended thread. This happens because the error message bypasses thread routing — metadata (containing thread_id) is not properly handled.

Steps to Reproduce

  1. Send a message with MEDIA:/nonexistent/path/file.png in a Matrix thread
  2. The file does not exist
  3. Error message (file not found: /path) appears in the main room, not the thread

Expected Behavior

Current code (gateway/platforms/matrix.py, ~line 1359)

if not p.exists():
    return await self.send(
        room_id, f"{caption or ''}\n(file not found: {file_path})", reply_to,
        metadata=metadata
    )

Actual Behavior

Proposed fix

Silently skip the missing file and log a warning:

if not p.exists():
    logger.warning("Matrix: MEDIA file not found, skipping: %s", file_path)
    return SendResult(success=False, error=f"file not found: {file_path}")

This avoids sending confusing error messages to the wrong location.

Environment

  • Platform: Matrix
  • Use case: Sending generated files that may fail to create

### Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

### Messaging Platform (if gateway-related)

_No response_

### Debug Report

```shell
-

Operating System

Ubuntu 24.04

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

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