Repository navigation
fix(discord): upload-file silently drops a caption - #124255
Conversation
Both channels accept `media` as an alias for the uploaded file, so a send-shaped call reaches `upload-file` carrying its text in `caption`. Discord read only `message`/`content` and MS Teams read only `text`/`content`/`message`, so that text was dropped and the file landed with no message at all. Accept `caption` as the lowest-precedence alias on both channels, matching the WhatsApp and Slack upload paths. An explicitly empty higher-precedence value still wins, so existing callers keep their behavior. The MS Teams reader is scoped to `upload-file` because the other actions carry their own text field.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 3:46 PM ET / 19:46 UTC. ClawSweeper reviewWhat this changesThe PR makes Discord Merge readinessKeep open: current main still drops caption-only Discord upload text, and this is a focused owner-local repair with no blocking correctness finding. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe generic message tool hydrates attachment inputs and dispatches them to the Discord plugin. Discord’s upload-file handler turns those inputs into a flowchart LR
A[Message tool input] --> B[Attachment hydration]
B --> C[Discord upload-file handler]
C --> D[Text precedence]
D --> E[Discord sendMessage runtime]
E --> F[Attachment with message text]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +72. Total +76 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the owner-local caption fallback and its precedence tests; no net-neutral refactor can express the added input alias without losing the explicit contract. Do we have a high-confidence way to reproduce the issue? Yes: current main’s upload-file branch omits caption, while the PR’s documented main/control run and focused regression case isolate the resulting empty outbound content. Is this the best way to solve the issue? Yes: the Discord plugin owns translation of upload-file parameters into sendMessage content, and existing Slack and WhatsApp implementations confirm the same lowest-precedence alias without requiring a core contract change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3376c2980016. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Microsoft Teams keeps the same defect and the same fix shape, but a Teams after-fix delivery or activity trace is not reachable without a live tenant, so that half is deferred to its own change rather than blocking the Discord repair that already has a production-boundary trace.
|
Refreshed onto Two things had gone stale.
Re-measured, Windows 11, Node 24.18.1
The failing case on the control arm is the one this PR exists for:
|
|
Merged via squash.
|
* fix(discord,msteams): upload-file silently drops a caption Both channels accept `media` as an alias for the uploaded file, so a send-shaped call reaches `upload-file` carrying its text in `caption`. Discord read only `message`/`content` and MS Teams read only `text`/`content`/`message`, so that text was dropped and the file landed with no message at all. Accept `caption` as the lowest-precedence alias on both channels, matching the WhatsApp and Slack upload paths. An explicitly empty higher-precedence value still wins, so existing callers keep their behavior. The MS Teams reader is scoped to `upload-file` because the other actions carry their own text field. * refactor: narrow this PR to the Discord channel Microsoft Teams keeps the same defect and the same fix shape, but a Teams after-fix delivery or activity trace is not reachable without a live tenant, so that half is deferred to its own change rather than blocking the Discord repair that already has a production-boundary trace.
What Problem This Solves
Fixes an issue where users asking an agent to send a file with an explanation on Discord would receive the file with no message text at all.
The
messagetool lets a model attach text to a file two ways:message(orcontent) andcaption. Becauseupload-fileacceptsmediaas an alias for the file, a model can reach it with the same vocabulary it uses for a mediasend— and that vocabulary carries its text incaption. On Discord that caption was never read, so the text was dropped silently: the file arrived, the explanation did not, and the agent reported success.This is the same defect that was fixed for Slack in #121047. WhatsApp already handled it.
Why This Change Was Made
Discord now accepts
captionas the lowest-precedence text alias onupload-file, matching the WhatsApp and Slack upload paths:upload-filetext resolutionmessage ?? content ?? caption(extensions/whatsapp/src/channel-react-action.ts:51-57)initialComment ?? message ?? caption(extensions/slack/src/message-action-dispatch.ts:358-365)message ?? content(extensions/discord/src/actions/handle-action.ts:278-280)Precedence is preserved exactly as Slack's fix defined it: an explicitly empty higher-precedence value still wins, so a caller passing
message: ""keeps an empty message instead of silently inheriting the caption.Scope. This PR started out covering Microsoft Teams as well, which carries the same defect in
resolveActionContent(extensions/msteams/src/channel.ts:237-245) and would take the same shape of fix. I narrowed it to Discord because a Teams after-fix delivery or activity trace is not reachable without a live tenant, and I would rather not hold up a repair that does have a production-boundary trace. The Teams half is deliberately left for a separate change; I am happy to open it if a maintainer is comfortable landing it on committed handler coverage, or to revisit it if a Teams-side injection seam exists that I did not find.Channels outside this scope, and why: iMessage routes
upload-filetosendAttachment, whose bridge payload carries no text field (extensions/imessage/src/actions.ts:755); Google Chat rejectsupload-fileoutright (extensions/googlechat/src/actions.ts:47); Telegram does not register the action.User Impact
On Discord, a file uploaded with a caption now arrives with that caption as the message text instead of arriving bare. Callers that pass
messageorcontentsee no change, including callers that pass an explicitly empty one.Evidence
AI-assisted change. Measured locally on Node 24.18.1 against
mainat1db88feeef0.The upper layer does not compensate.
hydrateAttachmentParamsForActionenables a caption fallback forupload-file, but it only copiesmessageintocaption, never the reverse (src/infra/outbound/message-action-params.ts:640-646). So a call carrying onlycaptionreaches the channel handler withmessagestill unset.Real delivery proof — real REST client over a real socket
This drives the real
upload-fileaction through the real Discord messaging runtime, the real media validator, and the realRequestClient, against a realnode:httpserver on loopback. Nothing in the channel path is stubbed; the only substitution is where the socket terminates —https://discord.com/apiis rerouted tohttp://127.0.0.1:<port>at thefetchboundary thatRequestClientalready uses (extensions/discord/src/internal/rest.ts:250,(this.customFetch ?? fetch)(url, ...)). The repository's own REST tests use the same loopback shape (extensions/discord/src/internal/rest.test.ts:896).The assertion is made on the bytes Discord would have received: the
payload_jsonpart of the real multipart request.This branch:
Control — same branch, same harness,
handle-action.tsrestored fromorigin/main(git checkout origin/main -- extensions/discord/src/actions/handle-action.ts):The file is uploaded in both runs and the tool reports
ok: truein both runs — onmainthe outbound message simply carries nocontentfield at all, which is the silent text loss this PR fixes. One file differs between the two runs.Harness (run with
node --import tsx proof-caption.mtsfrom the repo root; not committed)Tests
Three committed cases cover the alias and its precedence: a caption-only call,
messagewinning overcaption, and an explicitly emptymessagestaying empty. The last two pass with and without the fix, which confirms the change adds the missing alias without shifting existing precedence.oxlintandoxfmt --checkare clean on both touched files. The localtsgorun reports only pre-existing errors in untouched script and build files (missing declarations for.mjsmodules in a checkout without a priorpnpm build); that file set does not intersect the files changed here.Note on overlap: #123748 also edits the Discord
upload-fileblock, adding a buffer guard above the media check. It does not touch the text-resolution lines, so the two changes are independent.