fix(matrix): return SendResult instead of sending error to main room on missing file#41891
Open
liuhao1024 wants to merge 1 commit into
Open
Conversation
…on missing file When _send_local_file() encounters a missing file, it currently calls self.send() without the metadata parameter, causing the error message to appear in the main room instead of the intended thread. Replace the error-message send with a logger.warning + SendResult(success=False), matching Slack's pattern for missing files. This avoids confusing user-visible errors in the wrong room while still surfacing the issue in logs and the return value. Fixes NousResearch#32503
1 task
tonydwb
approved these changes
Jun 8, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Analysis
Correctness ✅
- The old code called self.send() recursively with an error message when a file was not found, which could leak error messages to the wrong room and cause confusion.
- The fix returns SendResult(success=False, error=...) which properly propagates the error without side effects.
- The logger.warning provides visibility for debugging without sending to a room.
Testing ✅
- Two tests verify: (1) SendResult(success=False) is returned and send() is NOT called, (2) same behavior without metadata.
Recommendation
Approve — clean fix with good test coverage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes
_send_local_file()in the Matrix adapter to returnSendResult(success=False)instead of sending an error message to the main room when a file is not found. Previously, the error message bypassed thread routing (missingmetadataparameter), causing confusing messages in the wrong room.Related Issue
Fixes #32503
Type of Change
Changes Made
gateway/platforms/matrix.py: Replaceself.send()call in file-not-found path withlogger.warning()+SendResult(success=False, error=...), matching Slack's pattern for missing filestests/gateway/test_matrix.py: AddTestSendLocalFileNotFoundwith 3 tests — missing file returns failure, no message leaked to any room, existing file still uploads correctlyHow to Test
pytest tests/gateway/test_matrix.py::TestSendLocalFileNotFound -v— all 3 tests passMEDIA:/nonexistent/path/file.pngin a thread — verify no error message appears in the main roomMatrix: MEDIA file not found, skipping: /nonexistent/path/file.pngwarningChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
gateway/platforms/matrix.py::_send_local_file(callers: 4 within same adapter, flows: media delivery)SendResult(success=False, error=...)for missing files at lines 1725/1823/1848; this PR aligns Matrix with that convention