The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(matrix): don't give install advice in the encrypted-drop warning when E2EE is on
kshitijk4poor1680245d7e5c
diff --git a/plugins/platforms/matrix/adapter.py b/plugins/platforms/matrix/adapter.pyindex 75e563dc72f..b99585700af 100644--- a/plugins/platforms/matrix/adapter.py+++ b/plugins/platforms/matrix/adapter.py@@ -1956,11 +1956,15 @@ class MatrixAdapter(BasePlatformAdapter):events = ((room_data or {}).get("timeline", {}) or {}).get("events", ()) or ()if any(isinstance(ev, dict) and ev.get("type") == "m.room.encrypted" for ev in events):self._warned_encrypted_drop_rooms.add(room_id)+ if self._e2ee_mode == "off":+ cause = f"{_E2EE_INSTALL_HINT}, then set MATRIX_E2EE_MODE=optional (or required)"+ else:+ cause = (f"E2EE mode is {self._e2ee_mode} but the decryptor was not set up at connect; "+ "see the earlier Matrix E2EE warning for the cause")logger.warning(- "Matrix: dropping encrypted messages in %s — this process has no E2EE decryptor "- "(E2EE off or unavailable). %s, then set MATRIX_E2EE_MODE=optional (or required). "+ "Matrix: dropping encrypted messages in %s — this process has no E2EE decryptor. %s. ""Without it, messages in encrypted rooms never reach the agent.",- room_id, _E2EE_INSTALL_HINT)+ room_id, cause)async def _dispatch_sync(self, sync_data: Dict[str, Any]) -> None:"""Dispatch a sync response through the mautrix event machinery."""diff --git a/tests/gateway/test_matrix.py b/tests/gateway/test_matrix.pyindex 7de2fb82131..4161ae63142 100644--- a/tests/gateway/test_matrix.py+++ b/tests/gateway/test_matrix.py@@ -1181,12 +1181,18 @@ class TestMatrixSyncLoop:return fake_client@pytest.mark.asyncio+ @pytest.mark.parametrize("mode, hint", [+ ("off", "set MATRIX_E2EE_MODE=optional"),+ # Degraded optional mode: the install/enable advice is wrong; point at the setup failure.+ ("optional", "E2EE mode is optional but the decryptor was not set up"),+ ])async def test_absorb_sync_warns_once_per_room_for_encrypted_events_without_crypto(- self, caplog+ self, caplog, mode, hint):"""Encrypted events with no decryptor must fail loud, once per room (#131778)."""adapter = _make_adapter()adapter._closing = False+ adapter._e2ee_mode = modefake_client = self._cryptoless_client()adapter._client = fake_client@@ -1205,7 +1211,8 @@ class TestMatrixSyncLoop:warnings = [r.getMessage() for r in caplog.records if "encrypted" in r.getMessage()]assert len(warnings) == 1- assert "!enc:example.org" in warnings[0] and "MATRIX_E2EE_MODE" in warnings[0]+ assert "!enc:example.org" in warnings[0] and hint in warnings[0]+ assert (mode == "off") == ("pip install" in warnings[0])@pytest.mark.asyncioasync def test_absorb_sync_no_encrypted_warning_when_crypto_attached(self, caplog):