Repository navigation
fix(mattermost): keep server file name when the download fails - #129556
Conversation
openclaw#129140 propagates the attachment file name into the model context, but only on the successful-download path. The failed-download fallback already calls /files/{id}/info and reads mime_type while discarding the name the same response carries — and on that branch the name is the only context the model gets about the attachment, since there is no local file. Read it and forward it like the success path does; blank names stay omitted.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 12:15 AM ET / 04:15 UTC. ClawSweeper reviewWhat this changesThe PR preserves sanitized server-provided filenames in Mattermost’s unavailable-attachment notice when a download fails. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo blocking findings. This PR still addresses a current-main omission: Mattermost’s failed-download fallback obtains file metadata but drops its name before constructing the agent-visible unavailable-attachment notice. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherMattermost inbound posts resolve attachments before dispatching an agent turn. A failed download falls back to the Mattermost file-info response, then the plugin renders a bounded notice into the agent body and structured media context. flowchart LR
A[Mattermost post] --> B[Attachment resolver]
B --> C{Download succeeds?}
C -->|Yes| D[Saved media metadata]
C -->|No| E[Server file metadata]
D --> F[Inbound agent context]
E --> G[Sanitized unavailable notice]
G --> F
F --> H[Agent turn]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +12, Tests +72. Total +84 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the bounded owner-plugin repair once the exact head is green; retain the existing no-extra-request fallback and its sanitization and dispatch-boundary coverage. Do we have a high-confidence way to reproduce the issue? Yes. The PR provides a concrete current-main failure path using a real Mattermost upload plus forced size-cap download failure, and current-main source confirms the fallback discards the returned name. Is this the best way to solve the issue? Yes. The repair keeps the existing metadata request, records the name at the fallback producer, and renders it only through the established bounded unavailable-media notice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3e0d9a6fd2df. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Preserve server-provided attachment names through the Mattermost-owned unavailable-media notice, safely bound model-visible metadata, and cover the actual posted-event dispatch boundary. Co-authored-by: goffern <[email protected]>
Inherit the maintainer-repaired Control UI startup baseline while preserving the reviewed Mattermost attachment filename repair and end-to-end regression coverage unchanged. Co-authored-by: goffern <[email protected]>
|
Maintainer verification for exact signed head 63908e4: the complete Mattermost failed-download path now reaches the actual model. Existing authenticated file-info metadata flows through the Mattermost-owned, sanitized, JSON-quoted, 512-unit-bounded unavailable notice into BodyForAgent; unavailable facts remain non-hydratable. Anonymous, plural, mixed, blank, malicious, and actual posted-websocket cases are covered. Original contributor @goffern remains credited. Proof: real Mattermost Docker upload plus forced size-cap failure and authenticated file-info request; isolated owner suite passed 21/21 twice; exact CI 32929115262 succeeded; exact Workflow Sanity 32929115225 succeeded; trusted formatting/lint and separate full-branch plus independent final reviews clean. Production net +12 provides genuinely model-visible context and bounded untrusted-input handling. An initial unrelated UI gzip failure was just three bytes over its prior limit; the signed branch refresh inherited the already-merged canonical baseline repair without adding UI changes. Ready for native maintainer merge. |
|
Merged via squash.
|
…law#129556) * fix(mattermost): keep server file name when the download fails openclaw#129140 propagates the attachment file name into the model context, but only on the successful-download path. The failed-download fallback already calls /files/{id}/info and reads mime_type while discarding the name the same response carries — and on that branch the name is the only context the model gets about the attachment, since there is no local file. Read it and forward it like the success path does; blank names stay omitted. * fix(mattermost): surface unavailable attachment filenames to agents Preserve server-provided attachment names through the Mattermost-owned unavailable-media notice, safely bound model-visible metadata, and cover the actual posted-event dispatch boundary. Co-authored-by: goffern <[email protected]> --------- Co-authored-by: goffern <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
#129140 made attachment file names reach the model context, but only on the successful-download path. The failed-download fallback in
extensions/mattermost/src/mattermost/monitor-resources.tsalready callsGET /files/{id}/infoand keepsmime_typewhile discarding thenamethe same response carries. On exactly the branch where the model gets no local file, the server-side file name is the only context available about the attachment — and it was dropped, reproducing the symptom #129140 fixed.Why This Change Was Made
Read
namefrom the/files/{id}/inforesponse that is already being fetched (zero additional requests) and forward it the same way the success path forwardssaved.fileName; blank names stay omitted rather than becoming empty strings. The success path is untouched: it gets the name from the download response, which the server populates from the same storedFileInfo.Production LOC is +7/−2, confined to the existing fallback block.
User Impact
When a Mattermost attachment cannot be downloaded (size cap, transient failure), the model now still sees the attachment's real file name alongside its type, instead of an anonymous
[attachment unavailable]fact.Evidence
Environment: real Mattermost (
mattermost/mattermost-previewDocker) on a throwaway EC2; checkoutc94b0bd92d; runs vianode scripts/run-vitest.mjs.1. Regression test fails on pre-fix code — the existing "keeps partial download failures aligned with native media metadata" test already mocked
/files/{id}/inforeturning aname; asserting the name is now forwarded fails on stockmain:2. Branch:
monitor-resources.test.ts18/18 green.3. Live BEFORE/AFTER — real upload, real failed download, real
/files/{id}/info: uploadedquarterly report final.pdfto a real channel, forced the download to fail withmediaMaxBytes: 1(the realsaveRemoteMediastarts the download and rejects on size), letting the real fallback branch hit the live server:Stock
mainreturns the fact without a name; the branch returnsfileName: "quarterly report final.pdf"from the live server metadata.