hermes - ✅(Solved) Fix [Bug]: Matrix encrypted upload test fails when mautrix deps are unavailable on non-Linux [1 pull requests, 1 participants]

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…
GitHub stats
NousResearch/hermes-agent#11679Fetched 2026-04-18 05:59:25
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Error Message

E + where False = SendResult(success=False, message_id=None, error="No module named 'mautrix'", raw_response=None, retryable=False).success ERROR gateway.platforms.matrix:matrix.py:1011 Matrix: attachment encryption failed: No module named 'mautrix'

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Strongly suggested mismatch between packaging policy and test assumptions:

  • pyproject.toml under all extra includes Matrix only on Linux:
    • "hermes-agent[matrix]; sys_platform == 'linux'"
  • Test expects encryption path that imports mautrix.crypto.attachments.

Fix Action

Fix / Workaround

Proposed Fix (optional)

Any of these would resolve the mismatch:

  1. Add dependency/platform guard and skip this test when mautrix E2EE deps are unavailable.
  2. Patch in fake mautrix.crypto.attachments.encrypt_attachment for this specific test path.
  3. Split Matrix E2EE tests behind a marker and run only on compatible environments.

PR fix notes

PR #11724: test(matrix): make encrypted upload coverage independent of optional mautrix deps

Description (problem / solution / changelog)

Summary

  • make the Matrix encrypted-upload regression test independent of optional local mautrix E2EE installs
  • inject the existing fake mautrix.crypto.attachments.encrypt_attachment module for the encrypted upload case
  • keep the test validating ciphertext upload plus file payload semantics on non-Linux dev machines

Why

tests/gateway/test_matrix.py::TestMatrixUploadAndSend::test_upload_encrypted_room_uses_file_payload currently fails on macOS and other environments where Matrix encryption deps are intentionally absent from .[all,dev]. That turns a packaging difference into a false-red test failure instead of exercising the adapter logic.

This patch keeps the test meaningful without weakening production behavior: it still verifies the encrypted-room branch, but it no longer depends on host-specific optional deps being installed.

Testing

  • python3 -m pytest -o addopts= tests/gateway/test_matrix.py::TestMatrixUploadAndSend::test_upload_encrypted_room_uses_file_payload -q
  • python3 -m pytest -o addopts= tests/gateway/test_matrix.py::TestMatrixUploadAndSend -q
  • python3 -m pytest -o addopts= tests/gateway/test_matrix.py -q

Closes #11679

Changed files

  • tests/gateway/test_matrix.py (modified, +5/-3)

Code Example

uv venv .venv --python 3.11
   source .venv/bin/activate
   uv pip install -e ".[all,dev]"

---

python -m pytest tests/gateway/test_matrix.py::TestMatrixUploadAndSend::test_upload_encrypted_room_uses_file_payload -q -n 0 --tb=short

---

assert result.success is True
E assert False is True
E + where False = SendResult(success=False, message_id=None, error="No module named 'mautrix'", raw_response=None, retryable=False).success

---

ERROR gateway.platforms.matrix:matrix.py:1011 Matrix: attachment encryption failed: No module named 'mautrix'
RAW_BUFFERClick to expand / collapse

Bug Description

tests/gateway/test_matrix.py::TestMatrixUploadAndSend::test_upload_encrypted_room_uses_file_payload fails on non-Linux dev environments where mautrix is not installed by default.

The repository currently makes Matrix extra Linux-only under .[all], but this test still expects encrypted upload behavior and fails with missing import instead of skipping/mocking.

Steps to Reproduce

  1. Fresh dev install:
    uv venv .venv --python 3.11
    source .venv/bin/activate
    uv pip install -e ".[all,dev]"
  2. Run the test directly:
    python -m pytest tests/gateway/test_matrix.py::TestMatrixUploadAndSend::test_upload_encrypted_room_uses_file_payload -q -n 0 --tb=short

Expected Behavior

On environments where Matrix encryption deps are intentionally absent, this test should either:

  • be skipped with a clear reason, or
  • fully mock dependency requirements so behavior is still testable.

It should not fail due to dependency availability mismatch.

Actual Behavior

Test fails with:

assert result.success is True
E assert False is True
E + where False = SendResult(success=False, message_id=None, error="No module named 'mautrix'", raw_response=None, retryable=False).success

Captured log:

ERROR gateway.platforms.matrix:matrix.py:1011 Matrix: attachment encryption failed: No module named 'mautrix'

Affected Component

  • Gateway (Telegram/Discord/Slack/WhatsApp)
  • Other

(Other = Matrix adapter + test dependency gating)

Messaging Platform (if gateway-related)

  • N/A (CLI only)

Debug Report

N/A for this report (unit test / dependency gating issue).

Operating System

macOS (arm64)

Python Version

3.11.15

Hermes Version

0.10.0

Additional Logs / Traceback (optional)

Relevant implementation path hit during failure:

  • Matrix adapter encrypted-upload import path (mautrix.crypto.attachments.encrypt_attachment).

Root Cause Analysis (optional)

Strongly suggested mismatch between packaging policy and test assumptions:

  • pyproject.toml under all extra includes Matrix only on Linux:
    • "hermes-agent[matrix]; sys_platform == 'linux'"
  • Test expects encryption path that imports mautrix.crypto.attachments.

So non-Linux contributors can hit deterministic false-reds.

Proposed Fix (optional)

Any of these would resolve the mismatch:

  1. Add dependency/platform guard and skip this test when mautrix E2EE deps are unavailable.
  2. Patch in fake mautrix.crypto.attachments.encrypt_attachment for this specific test path.
  3. Split Matrix E2EE tests behind a marker and run only on compatible environments.

Are you willing to submit a PR for this?

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

extent analysis

TL;DR

To fix the test failure, add a dependency or platform guard to skip the test_upload_encrypted_room_uses_file_payload test when mautrix E2EE dependencies are unavailable on non-Linux environments.

Guidance

  • Identify the test_upload_encrypted_room_uses_file_payload test in tests/gateway/test_matrix.py and consider adding a skip condition based on the availability of mautrix dependencies.
  • Use a try-except block to catch the ImportError exception when importing mautrix.crypto.attachments and skip the test if the import fails.
  • Consider using a test marker to run Matrix E2EE tests only on compatible environments, such as Linux.
  • Review the pyproject.toml file to ensure that the packaging policy aligns with the test assumptions.

Example

import pytest

try:
    from mautrix.crypto.attachments import encrypt_attachment
except ImportError:
    pytest.skip("mautrix E2EE dependencies are not available")

# Rest of the test code

Notes

The proposed fix assumes that the mautrix dependencies are not available on non-Linux environments. However, it's essential to verify that this assumption is correct and that the fix does not introduce any unintended consequences.

Recommendation

Apply a workaround by adding a dependency or platform guard to skip the test when mautrix E2EE dependencies are unavailable. This approach ensures that the test does not fail due to dependency availability mismatch and allows contributors to run the test on compatible environments.

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 - ✅(Solved) Fix [Bug]: Matrix encrypted upload test fails when mautrix deps are unavailable on non-Linux [1 pull requests, 1 participants]