Skip to content

fix(gateway): resolve canonical media params on message.action dispatch - #112490

Closed
harjothkhara wants to merge 1 commit into
openclaw:mainfrom
harjothkhara:fix/feishu-unsupported-attachment-param
Closed

harjothkhara wants to merge 1 commit into
openclaw:mainfrom
harjothkhara:fix/feishu-unsupported-attachment-param

Conversation

@harjothkhara

Copy link
Copy Markdown
Contributor

What Problem This Solves

Closes #112244.

A gateway message.action send carrying a canonical attachment was silently dropped and reported success:

{"action":"send","channel":"feishu","message":"hello","attachments":[{"media":"/tmp/script.py"}]}
→ {"ok":true,"channel":"feishu","action":"send"}   // attachment never sent

The root cause is not channel-specific. There are two dispatch paths:

  • Outbound runner — buildSendPayloadParts resolves the canonical media alias chain (media → mediaUrl/path/filePath/fileUrl/image → mediaUrls → attachments[]) into the media param adapters read.
  • Gateway message.action — never reaches that code. hydrateAttachmentParamsForAction handles only buffer for send and returns early, then dispatch goes straight to the plugin.

So on the gateway path the adapter received attachments with no media, found nothing to send, and fell through to a text-only send. Feishu surfaced it first because it is the channel with a single-media-string transport, but any channel reading media has the same hole.

Why This Change Was Made

Resolve the same chain on the gateway path, and give both paths one collector so their precedence cannot drift. buildSendPayloadParts now consumes collectSendMediaSources, and its duplicate collectMessageAttachmentMediaHints is deleted (runner is −57 lines).

Before unification the two paths genuinely disagreed: for {path: A, mediaUrl: B} the runner picked B and a naive gateway resolver picked A. One collector makes that class of bug unrepresentable.

Feishu additionally fails fast on what it cannot deliver, rather than dropping it:

  • file and attachment — the only two media spellings core never resolves.
  • More than one media item — Feishu delivers one per message; the second was dropped silently.
  • Media on thread-reply — no dispatch path resolves media for that action, so it always delivered text only.

Deliberately not rejected: path, filePath, mediaUrl, fileUrl, image, mediaUrls, attachments, and their snake_case spellings. Core resolves all of these (readStringParam → resolveSnakeCaseParamKey), and blocking them would regress working sends. There is a regression test pinning file_path.

User Impact

  • Canonical attachments now deliver on gateway message.action sends instead of silently vanishing behind ok:true.
  • Feishu returns an actionable error for unsupported/multi/thread-reply media instead of a false success.
  • No change to the outbound runner's delivered output; it is byte-identical, now sourced from the shared collector.
  • Fail-closed note: attachment/file, multi-media, and thread-reply media on Feishu now error where they previously returned ok:true without sending. That is the reported bug, but it is a behavior change worth calling out.

Evidence

Red-green on the call site — send.test.ts fails with the resolve call removed, passes with it restored:

# with normalizeSendMediaParams(request.params) removed from send.ts
× resolves canonical attachments into media before dispatching message action sends
  Tests  1 failed | 78 passed (79)

# restored
  Tests  79 passed (79)

Full suites (Node 22.22.3):

node scripts/run-vitest.mjs run \
  src/gateway/server-methods/send.test.ts \
  extensions/feishu/src/channel.test.ts \
  src/infra/outbound/message-action-params.test.ts \
  src/infra/outbound/message-action-runner.media.test.ts \
  src/infra/outbound/message-action-runner.plugin-dispatch.test.ts

Tests  79 passed (79)    # gateway
Tests  123 passed (123)  # outbound params + runner media + plugin dispatch
Tests  112 passed (112)  # feishu

Lint/format: oxfmt --check clean on all changed files; check-max-lines-ratchet OK. message-action-params.ts still trips raw oxlint max-lines, but it was already over at baseline (753 lines) and is grandfathered — this change does not move it past the enforced gate.

pnpm check:changed delegates to Blacksmith Testbox, which is unavailable in my environment (executable file not found), so I ran the underlying linters and the affected suites directly.

Sibling-surface note: outbound-send-service.ts also calls dispatchChannelMessageAction, but it is reached from the runner after buildSendPayloadParts, so it was already covered and is unaffected.

Known follow-ups (not in this PR, to keep it focused)

On the gateway path these remain unresolved and are pre-existing:

  • attachments: [{ buffer, filename }] — no collector reads a per-attachment buffer.
  • caption without message — the runner folds it into message; the gateway does not.
  • extraParamKeys — plugin-declared media params are resolved on the runner path only.
  • assertMediaNotDataUrl is not applied to newly resolved values (a caller could already pass media: "data:…" directly on this path).

Happy to take any of these in a follow-up, or fold one in here if you'd prefer.

Duplicate-work check

gh issue view 112244 --repo openclaw/openclaw --comments        # open, unassigned, no claim
gh pr list --repo openclaw/openclaw --state open --search "112244 in:body"   # []
gh pr list --repo openclaw/openclaw --state open --search "feishu attachment media"

No open PR references #112244. The nearby Feishu PRs are different concerns: #102397 (text/media ordering), #108588 (inbound durable attachment), #102650 (card image embed). None touches send-param resolution or gateway media dispatch.

AI assistance disclosure

This change was developed with AI assistance (Claude). I reviewed every changed line, ran the tests above myself, and can defend the design end-to-end. Attribution is in the commit trailer (Co-authored-by: Claude).

Notably, AI review caught two defects in earlier iterations of this patch that I had to correct before submitting: an over-broad denylist that would have rejected core-resolved snake_case aliases, and a media promotion that ran before sandbox normalization and produced un-normalized paths. Both are covered by tests here.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime channel: feishu Channel integration: feishu size: M labels Jul 22, 2026
@harjothkhara
harjothkhara force-pushed the fix/feishu-unsupported-attachment-param branch 2 times, most recently from 227262d to ee770e9 Compare July 22, 2026 04:34
Gateway `message.action` sends never reach the outbound runner's send payload
build, which is where the canonical media alias chain (`media` ->
`mediaUrl`/`path`/`filePath`/`fileUrl`/`image` -> `mediaUrls` -> `attachments[]`)
is resolved. A caller-supplied attachment therefore arrived at the channel
adapter with no `media` set and was silently dropped, reporting a successful
text-only send.

Resolve the same chain on the gateway path, and give both paths a single
collector in `send-media-sources.ts` so their precedence cannot drift:
`buildSendPayloadParts` now consumes it and its duplicate
`collectMessageAttachmentMediaHints` is deleted.

Feishu additionally rejects the two media sources core never resolves (`file`,
`attachment`), multi-media sends it cannot deliver, and media on `thread-reply`,
which no dispatch path resolves — each of which previously delivered text only.

Co-authored-by: Claude <[email protected]>
@harjothkhara
harjothkhara force-pushed the fix/feishu-unsupported-attachment-param branch from ee770e9 to 388921b Compare July 24, 2026 00:58
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 25, 2026
@clawsweeper

clawsweeper Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 9:55 AM ET / 13:55 UTC.

ClawSweeper review

What this changes

The branch normalizes canonical media attachment aliases for gateway message.action sends, shares that resolution with the outbound runner, and makes Feishu reject unsupported, multi-media, or media-bearing thread-reply sends instead of falsely reporting success.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

This PR addresses the reported silent media-loss path with a focused shared resolver and passing CI, and it remains necessary because current main does not normalize canonical attachment aliases before gateway message.action dispatch. The patch appears correct from the reviewed source and tests, but it needs redacted after-fix Feishu behavior proof before merge because the PR changes real message delivery and deliberate fail-closed outcomes.

Priority: P2
Reviewed head: 388921b9342e0249d6057160bac17fb03716e614

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused coverage are solid, but missing real channel behavior proof remains a merge gate for this external delivery-path PR.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR provides focused tests and CI, including a red-green unit demonstration, but no redacted after-fix run against a real Feishu gateway/channel setup; add live output, logs, or a recording without private data before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR provides focused tests and CI, including a red-green unit demonstration, but no redacted after-fix run against a real Feishu gateway/channel setup; add live output, logs, or a recording without private data before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current-main gap: Current main dispatches message.action directly to dispatchChannelMessageAction without importing or calling the proposed media normalizer, so the reported gateway-only alias gap remains unresolved.
Focused implementation: The PR adds normalizeSendMediaParams(request.params) on the gateway send path and extracts the runner's media-source collection into one shared helper, reducing precedence drift between the two dispatch paths.
Regression coverage: The branch adds gateway dispatch coverage for attachments, focused shared-normalizer tests, and Feishu action tests for recognized aliases, unsupported sources, multi-media, and thread replies.
Findings None None.
Security None None.

How this fits together

Gateway message.action invokes a channel plugin directly, while the outbound runner first prepares send parameters and media references. This PR brings gateway send dispatch onto the same canonical-media interpretation so channel adapters receive usable media fields rather than silently falling back to text-only delivery.

flowchart LR
  A[Gateway message action request] --> B[Gateway send preparation]
  C[Outbound runner request] --> D[Shared media-source collector]
  B --> D
  D --> E[Canonical media parameters]
  E --> F[Channel action dispatch]
  F --> G[Feishu delivery or actionable error]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR provides focused tests and CI, including a red-green unit demonstration, but no redacted after-fix run against a real Feishu gateway/channel setup; add live output, logs, or a recording without private data before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Feishu behavior changes from false-success text-only delivery to explicit errors for file, attachment, multiple media items, and media-bearing thread-reply; this is the intended compatibility tradeoff but needs a real after-fix channel run before merge.
  • Resolve merge risk (P1) - The supplied validation is unit and integration-style test evidence only; it does not demonstrate an actual Feishu gateway message.action attachment delivery or the new error receipts in a live setup.
  • Complete next step (P2) - The remaining merge blocker is contributor-supplied real behavior proof, which an automated repair lane cannot produce on the contributor’s Feishu setup.
Agent review details

Security

None.

PR surface

Source +111, Tests +262, Docs +4. Total +377 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 173 62 +111
Tests 3 263 1 +262
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 440 63 +377

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #112244
Summary: This PR is the open candidate implementation for the canonical Feishu silent-attachment-loss report; the other referenced Feishu PRs cover distinct inbound, card, or streaming-delivery behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Add real Feishu gateway proof (recommended)
    Before merge, capture a redacted live gateway message.action run showing canonical attachment delivery and the new fail-closed error for an unsupported or multi-media request.
  2. Accept the documented behavior change
    A maintainer may accept the fail-closed Feishu contract without additional live proof if the compatibility tradeoff is intentionally approved.

Technical review

Best possible solution:

Keep one shared canonical-media resolver, then add redacted live Feishu proof showing an attachments: [{media: ...}] gateway action delivers the file and unsupported or multi-media sends return the documented actionable error.

Do we have a high-confidence way to reproduce the issue?

Yes, from source and the supplied regression tests: gateway message.action bypasses the outbound runner’s media preparation, allowing canonical attachments to reach an adapter without media. A live Feishu run was not supplied for the proposed fix.

Is this the best way to solve the issue?

Yes, the shared collector is the narrowest maintainable fix because it prevents precedence drift between outbound-runner and gateway sends while keeping channel-specific transport limits in Feishu.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d1b534d7fac5.

Labels

Label justifications:

  • P2: This is a deterministic message-delivery repair with a bounded channel and gateway blast radius, not an availability or security emergency.
  • merge-risk: 🚨 message-delivery: The changed gateway and Feishu paths determine whether an attachment is delivered, rejected, or silently reduced to text.
  • merge-risk: 🚨 compatibility: Existing Feishu callers using unsupported or multi-media parameter shapes will receive an error instead of the prior misleading success response.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused tests and CI, including a red-green unit demonstration, but no redacted after-fix run against a real Feishu gateway/channel setup; add live output, logs, or a recording without private data before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main gap: Current main dispatches message.action directly to dispatchChannelMessageAction without importing or calling the proposed media normalizer, so the reported gateway-only alias gap remains unresolved. (src/gateway/server-methods/send.ts:1, d1b534d7fac5)
  • Focused implementation: The PR adds normalizeSendMediaParams(request.params) on the gateway send path and extracts the runner's media-source collection into one shared helper, reducing precedence drift between the two dispatch paths. (src/gateway/server-methods/send.ts:556, 388921b9342e)
  • Regression coverage: The branch adds gateway dispatch coverage for attachments, focused shared-normalizer tests, and Feishu action tests for recognized aliases, unsupported sources, multi-media, and thread replies. (src/gateway/server-methods/send.test.ts:2008, 388921b9342e)
  • Current CI: The supplied PR check state shows successful build, lint, type, channel-contract, security, and QA smoke lanes for the reviewed head; skipped matrix lanes do not alter the delivery-risk assessment. (388921b9342e)
  • Related report: The canonical bug report documents production Feishu text-only delivery with an ok:true receipt when attachment intent is supplied outside media; this PR explicitly targets that remaining gateway send path.

Likely related people:

  • forrystudio: Provided the concrete production Feishu reproduction, affected release evidence, and expected fail-fast behavior that define the user-facing contract this PR repairs. (role: reproduction reporter; confidence: medium; files: extensions/feishu/src/channel.ts, src/gateway/server-methods/send.ts)
  • NianJiuZst: Has an open, independently scoped Feishu media-delivery PR, making them a useful adjacent routing contact for channel-level delivery semantics rather than an owner of this branch. (role: adjacent Feishu delivery contributor; confidence: low; commits: 92e40e3d2e95; files: extensions/feishu/src/reply-dispatcher.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted live Feishu message.action transcript, terminal output, or recording proving canonical attachment delivery after the change.
  • Show one rejected unsupported or multi-media request so reviewers can verify the intentional fail-closed response.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@harjothkhara

Copy link
Copy Markdown
Contributor Author

Closing this branch as stale. #112244 stays open — the reported behavior has not been verified as fixed.

main has since restructured the message.action dispatch in src/gateway/server-methods/send.ts around an inflight/dedupe wrapper plus binding/account reconciliation, and this branch's normalizeSendMediaParams helper does not exist there at all. Reapplying the fix means rewriting it into the new control flow and re-proving it, which is cleaner as a fresh, smaller PR than as a conflict resolution on a base this far behind.

Happy to redo it that way against current main if the attachment-drop is still reproducible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Feishu message send silently drops unsupported attachment params (file/filePath/attachments/…) and returns ok:true — attachment never sent

1 participant