Repository navigation
fix(matrix): send fallback media when attachment list is blank - #128479
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 25, 2026, 12:56 PM ET / 16:56 UTC. ClawSweeper reviewWhat this changesThe PR makes Matrix automatic replies use the shared sendable-reply selector so blank plural media entries fall back to a valid singular attachment and fully blank replies record the normal diagnostic. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 3 items remain No blocking code defect found. Current main still uses the raw attachment checks this PR replaces, but the supplied homeserver proof predates the current head’s streaming-dispatch change, so exact-head automatic-reply proof is needed before merge. Priority: P2 Review scores
Verification
How this fits togetherMatrix automatic replies transform generated text and attachment fields into Matrix upload/send operations or an intentional suppressed result. The Plugin SDK selector provides normalized sendable text and media state to the Matrix delivery and draft-finalization paths. flowchart LR
A[Generated reply payload] --> B[Shared reply selector]
B --> C[Matrix reply delivery]
C --> D{Sendable content?}
D -->|Media or text| E[Upload and room event]
D -->|Neither| F[Missing-result diagnostic]
E --> G[Visible Matrix reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +152. Total +149 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Matrix automatic-reply delivery and streaming finalization on the shared selector, with one exact-head disposable-homeserver trace through the automatic-reply entry point proving fallback upload/send and blank-result suppression. Do we have a high-confidence way to reproduce the issue? Yes, by source: current main’s raw mediaUrls length check selects blank plural entries before the valid singular field, while the PR’s focused tests encode that failing shape. This review did not execute contributor code locally. Is this the best way to solve the issue? Yes. Reusing the existing Plugin SDK selector is the canonical owner-boundary repair; it removes Matrix-specific raw checks rather than adding another fallback policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 16c097b2dae9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Maintainer verification: exact final head The contributor's real disposable Tuwunel homeserver proof covers singular fallback upload, a visible Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/32874239548 passed all 67 jobs; Workflow Sanity https://github.com/openclaw/openclaw/actions/runs/32874239589 passed. Full final-branch structured review and a separate standalone independent review found no actionable defects. Original contributor @Alix-007 is preserved as the PR author and exact co-author. The prior stale-base/rebase rank-up remains intentionally skipped: the affected Matrix owner, dispatcher, tests, and shared selector have no conflicting current-main changes. The behavioral follow-up was applied at its canonical owner instead. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: Alix-007 <[email protected]>
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…law#128479) * fix(matrix): send fallback media when attachment list is blank * fix(matrix): align media validation and delivery * fix(matrix): reject whitespace-only reply parts * fix(matrix): normalize streamed reply media before draft finalization Co-authored-by: Alix-007 <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
AI-assisted: This change was implemented and validated with Codex.
What Problem This Solves
Matrix automatic replies could discard a valid singular attachment when
mediaUrlsexisted but contained only blank entries. The raw text/array checks and the normalized delivery list also disagreed when neither text nor media was sendable, allowing whitespace-only replies to end with neither a visible message nor the expected missing-result diagnostic.Why This Change Was Made
The Matrix automatic-reply path now resolves
hasText,hasMedia, andmediaUrlsonce through the Plugin SDK's canonical sendable-reply selector. Validation, missing-result reporting, and delivery therefore consume the same normalized state, while whitespace filtering and singular fallback remain owned by the shared selector.Sibling PR #128372 established the shared blank-list fallback. This PR connects the omitted Matrix automatic-reply consumer. PR #127653 covers shared fan-out and durable reconciliation, while #128254 changes reasoning-notice delivery in the same Matrix files; neither changes this selector or covers this failure.
User Impact
Matrix automatic replies now upload and send a valid fallback attachment when plural attachment entries are blank. A reply containing only whitespace text and blank media now records the normal
matrix reply missing text/mediaoutcome instead of disappearing silently.Evidence
6b04c79e5f03c9ca9a1b5aa0e5b0f4b4c0b31714. Original parent-red gate:c337919f6d4ff030bc46180fea89f7935fe46b4f. Upstream main at this body refresh:2aa5eee34e51d0655fd6e7dca1c41f1da1e53e04.node scripts/run-vitest.mjs extensions/matrix/src/matrix/monitor/replies.test.tsfailed only the new fallback regression: expectedhttps://example.com/fallback.jpg, received three spaces.e9f5e59df82682f012cd0443634ab78597e8a98d: blank-only media expectedmatrix reply missing text/media, but the error hook had zero calls and the send path emitted nothing.a4f70619cdbdbdb69c740988ac3fd6d07a0bb30b: whitespace text plus blank-only media again expected the diagnostic, but the error hook had zero calls. Exact head uses the selector's normalizedhasTextandhasMediafor the gate.node scripts/run-vitest.mjs extensions/matrix/src/matrix/monitor/replies.test.ts extensions/matrix/src/matrix/monitor/replies.file-boundary.test.tspassed 2 files / 20 tests. The boundary test reads a real temporary file throughloadOutboundMediaFromUrland exercises the production reply/send pipeline.pnpm exec oxfmt --checkpassed for all 3 changed files, andgit diff --checkpassed.Alix-007 <[email protected]>as author and committer.Real homeserver proof: fallback delivery
PR head
a4f70619cdbdbdb69c740988ac3fd6d07a0bb30b, the direct parent of the final normalized-text gate, was run against a disposable loopback Tuwunel v1.8.2 homeserver. The officialv1.8.2-release-all-x86_64-v1-linux-gnu-tuwunel.zstasset reported digestsha256:823796258f9252e0b1215d12e6190abba70d81a2a39efc86b419e5a6b3a2cd6c; the downloaded asset matched that SHA-256 before its static binary was started. The proof performed real token registration, created and joined a real room, then randeliverMatrixReplieswithmediaUrls: [" "]and a real local-filemediaUrl.{ "proof": "PASS", "source": "PR head a4f70619 deliverMatrixReplies", "homeserver": { "binary": "Tuwunel v1.8.2 static x86_64-v1", "releaseAssetSha256": "823796258f9252e0b1215d12e6190abba70d81a2a39efc86b419e5a6b3a2cd6c", "scope": "disposable loopback; base URL redacted" }, "fallback": { "plural": "blank-only", "singular": "local file selected" }, "upload": { "bytes": 30, "route": "/_matrix/media/v3/upload", "status": 200 }, "roomEvent": { "body": "fallback caption", "filename": "fallback.txt", "msgtype": "m.file", "route": "/_matrix/client/v3/rooms/{roomId}/send/m.room.message/{transactionId}", "status": 200, "type": "m.room.message", "urlScheme": "mxc" }, "roundTrip": { "bytes": 30, "route": "/_matrix/client/v1/media/download/{serverName}/{mediaId}", "sha256": "0ff5b069e913b3ee5670a1481165227a8c6dfd62033be45f5393601218fde9d0", "sourceMatchesDownload": true, "status": 200 }, "visibleReplySent": true, "eventCount": 1, "secretsPrinted": false }Real homeserver proof: normalized-empty no-event
The exact final head repeated the same checksum-pinned static homeserver setup, registered three fresh accounts, created and joined a fresh room, and ran
deliverMatrixReplieswith whitespace-only text and blank-only media. It then read the real room timeline from the homeserver.{ "proof": "PASS", "source": "exact head 6b04c79e deliverMatrixReplies", "homeserver": { "binary": "Tuwunel v1.8.2 static x86_64-v1", "releaseAssetSha256": "823796258f9252e0b1215d12e6190abba70d81a2a39efc86b419e5a6b3a2cd6c", "scope": "disposable loopback; base URL redacted" }, "input": { "text": "blank-only", "mediaUrls": "blank-only" }, "outcome": { "diagnostic": "matrix reply missing text/media", "suppression": "no_visible_result", "visibleReplySent": false }, "transport": { "uploadRequestCount": 0, "sendRequestCount": 0 }, "roomReadback": { "route": "/_matrix/client/v3/rooms/{roomId}/messages", "status": 200, "roomMessageEventCount": 0 }, "secretsPrinted": false }Both proofs omitted or normalized account IDs, room/event IDs, access tokens, registration tokens, loopback ports, and media IDs. Each Tuwunel process, binary, config, database, and payload was removed after exit; no external credentials or persistent room were used.
The repository's Compose-based fixture could not start on this host because its Docker 17.03.3 installation lacks the Compose plugin, and the same daemon rejected the modern image layer with
archive/tar: invalid tar header. The checksum-pinned official static release provided the equivalent real homeserver boundary without weakening TLS or artifact verification. During the first proof shutdown, the minimal non-persistent Matrix runtime logged one IndexedDB snapshot warning before its existing stop fallback completed; all transport assertions had already passed, the process exited 0, and all temporary state was removed. The exact-head no-event proof used the explicit non-persisting stop path and emitted no such warning.Limitations
The real homeservers were loopback-only and the rooms were unencrypted. The proofs cover registration, room creation/join, normalized empty-result handling, production attachment selection, real media upload, real room event storage/readback, and real media download; they do not exercise federation or an external operator-owned Matrix room.