Repository navigation
fix(discord): upload-file with a base64 buffer fails without pointing at send - #123748
Conversation
The flat message tool schema advertises buffer for every action, so callers reasonably infer upload-file + buffer is valid on Discord. The Discord handler only reads filePath/path/media for upload-file and failed with an error that never mentioned the supported path. Scope the buffer schema description to action="send" and make Discord upload-file reject a buffer-only call with guidance to use send instead of duplicating the send buffer pipeline under a second action.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 7:04 AM ET / 11:04 UTC. ClawSweeper reviewWhat this changesThe PR changes Discord’s buffer-only Merge readinessNo blocking findings. This is a focused Discord-plugin repair with convincing live before/after proof; GitHub reports it cleanly mergeable, though it is behind main and should receive current-base merge validation before landing. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe message tool routes an action and attachment parameters through the core message-action runner to a selected channel plugin. Discord’s flowchart LR
A[Agent or CLI message action] --> B[Message action runner]
B --> C[Attachment normalization]
C --> D[Discord action handler]
D --> E{File source supplied?}
E -->|Yes| F[Discord upload delivery]
E -->|Buffer only| G[Actionable send guidance]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +6, Tests +19. Total +25 across 2 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 the Discord-local redirect, preserve the channel-neutral shared schema for iMessage compatibility, and land after current-base validation confirms the exact merged result. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s Discord handler deterministically emits the generic error for buffer-only upload-file, and the PR body includes a real-channel before/after invocation path. Is this the best way to solve the issue? Yes. The mismatch is Discord-local; changing the shared flat schema would conflict with iMessage upload-file, which legitimately accepts a buffer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4af09d4961c9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
iMessage's upload-file deliberately consumes a buffer, so scoping the shared schema text to send would teach models away from a supported path. Keep the guidance owner-local: Discord's rejection carries it.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
… at send (openclaw#123748) * fix(discord): reject upload-file buffer attachments with send guidance The flat message tool schema advertises buffer for every action, so callers reasonably infer upload-file + buffer is valid on Discord. The Discord handler only reads filePath/path/media for upload-file and failed with an error that never mentioned the supported path. Scope the buffer schema description to action="send" and make Discord upload-file reject a buffer-only call with guidance to use send instead of duplicating the send buffer pipeline under a second action. * review: keep the shared buffer description channel-neutral iMessage's upload-file deliberately consumes a buffer, so scoping the shared schema text to send would teach models away from a supported path. Keep the guidance owner-local: Discord's rejection carries it.
Closes #123747
What Problem This Solves
Fixes an issue where callers sending in-memory bytes to Discord via
messagewithaction: "upload-file"and a base64bufferwould hitupload-file requires filePath, path, or media.with no hint thataction: "send"is the supported path. The flat tool schema advertisesbufferfor every action, so the failing shape is exactly what the schema invites.Why This Change Was Made
Owner-local fix only: Discord's
upload-filebranch now rejects a buffer-only call with guidance to usesend. Per review, the sharedbufferschema description is left channel-neutral — iMessage'supload-filedeliberately consumes a buffer (extensions/imessage/src/actions.ts), so send-only wording there would teach models away from a supported path. Supportingupload-file + bufferon Discord was deliberately not done — it would duplicate the existingsend + buffercapability (#90768) without a distinct use case. Calls with a valid file source are untouched.User Impact
Agents and operators get an actionable redirect instead of a dead end:
Use action: "send" for base64 buffer attachments; upload-file requires filePath, path, or media.Evidence
Real behavior (real Discord setup, live server)
Traces from a real Discord bot + server, driven through the same path
openclaw message <action>rides (runtime config → channel plugin preload →messageCommand→runMessageAction→ Discord plugin dispatch). Driver source is at the bottom; channel/message ids redacted.Before (unpatched
main,ffd42dd8a39) —upload-file+ valid base64buffer,filename,contentType, real channel target:After (this branch) — same call:
Redirect target works (this branch) — the guidance's
send + buffershape delivers a real attachment to the same live channel:The rejection fires in the Discord handler before any Discord API call, so the error-path traces involve no outbound request; the
sendtrace is a real delivery observed in the Discord client.Tests and static checks
upload-file+ buffer rejects with the actionable error and never reaches the channel runtime (extensions/discord/src/actions/handle-action.test.ts), alongside the existing buffer-less rejection test.extensions/discord/src/actions/handle-action.test.ts37/37 andsrc/agents/tools/message-tool.test.ts232/232 on this branch (rebased on currentmain);tsgocore+extensions test projects,oxlint, andoxfmt --checkclean on touched files.sendsuccess and invalid-base64 rejection (src/infra/outbound/message-action-params.test.ts),upload-filefile-source hydration (src/infra/outbound/message-action-params.attachments.test.ts), and iMessage's buffer-consumingupload-file(extensions/imessage/src/actions.test.ts).Proof driver source (local one-off, not part of the PR)
Run from the repo root with
OPENCLAW_HOMEpointing at an isolated state dir whoseopenclaw.jsoncontains onlychannels.discord.{enabled,token}, andOPENCLAW_BUNDLED_PLUGINS_DIR=$PWD/extensionsso the loader uses the source tree under test instead of a staledist/.