From 12b938d2d1bd5e11759b7f41237f2485e8599ef0 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Fri, 20 Mar 2026 12:18:29 +0200 Subject: [PATCH] Skip files with application/octet-stream MIME type Files with unrecognized MIME types (application/octet-stream) are not supported by any LLM provider and would cause errors that permanently break the conversation thread. Instead, represent them as a text message describing the attachment so the LLM is still aware a file was sent without the thread becoming unusable. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/conversation/matrix/utils/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/conversation/matrix/utils/mod.rs b/src/conversation/matrix/utils/mod.rs index f5f3e77..32c7ce3 100644 --- a/src/conversation/matrix/utils/mod.rs +++ b/src/conversation/matrix/utils/mod.rs @@ -312,6 +312,24 @@ pub async fn convert_matrix_native_event_to_matrix_message( tracing::debug!("Determined mime type {} for file {}", mime_type, file_name); + if mime_type == mxlink::mime::APPLICATION_OCTET_STREAM { + tracing::debug!( + "Skipping file {} with unsupported MIME type {}. It will be represented as a text message.", + file_name, + mime_type, + ); + + return Ok(Some(MatrixMessage { + sender_id: matrix_native_event.sender().to_owned(), + content: MatrixMessageContent::Text(format!( + "[A file ({}) was attached but skipped because its content type ({}) is not supported. Let the user know.]", + file_name, mime_type, + )), + mentioned_users, + timestamp, + })); + } + let span = tracing::debug_span!("get_media_content", file_name = %file_name, mime_type = %mime_type); let media_bytes = matrix_link