From a28ae51ce9acaff5be585a43390d4b81c4d360a7 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Wed, 11 Feb 2026 10:55:51 +0100 Subject: [PATCH] fix(matrix): handle matrix-nio upload tuple response --- nanobot/channels/matrix.py | 3 ++- tests/test_matrix_channel.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py index 28c3924..720aef7 100644 --- a/nanobot/channels/matrix.py +++ b/nanobot/channels/matrix.py @@ -517,12 +517,13 @@ class MatrixChannel(BaseChannel): return MATRIX_ATTACHMENT_UPLOAD_FAILED_TEMPLATE.format(filename) mime = mimetypes.guess_type(filename, strict=False)[0] or "application/octet-stream" - upload_response = await self.client.upload( + upload_result = await self.client.upload( data, content_type=mime, filename=filename, filesize=len(data), ) + upload_response = upload_result[0] if isinstance(upload_result, tuple) else upload_result if isinstance(upload_response, UploadError): logger.warning( "Matrix outbound attachment upload failed for {}: {}", diff --git a/tests/test_matrix_channel.py b/tests/test_matrix_channel.py index d625aca..533d615 100644 --- a/tests/test_matrix_channel.py +++ b/tests/test_matrix_channel.py @@ -133,7 +133,7 @@ class _FakeAsyncClient: ) if self.upload_response is not None: return self.upload_response - return SimpleNamespace(content_uri="mxc://example.org/uploaded") + return SimpleNamespace(content_uri="mxc://example.org/uploaded"), None async def content_repository_config(self): return self.content_repository_config_response