Repository navigation
fix(gateway): resolve canonical media params on message.action dispatch - #112490
harjothkhara wants to merge 1 commit into
Conversation
227262d to
ee770e9
Compare
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]>
ee770e9 to
388921b
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 25, 2026, 9:55 AM ET / 13:55 UTC. ClawSweeper reviewWhat this changesThe branch normalizes canonical media attachment aliases for gateway 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 Priority: P2 Review scores
Verification
How this fits togetherGateway 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +111, Tests +262, Docs +4. Total +377 across 8 files. View PR surface stats
Review metricsNone. 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 one shared canonical-media resolver, then add redacted live Feishu proof showing an Do we have a high-confidence way to reproduce the issue? Yes, from source and the supplied regression tests: gateway 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. LabelsLabel 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
|
|
Closing this branch as stale. #112244 stays open — the reported behavior has not been verified as fixed.
Happy to redo it that way against current |
What Problem This Solves
Closes #112244.
A gateway
message.actionsend 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 sentThe root cause is not channel-specific. There are two dispatch paths:
buildSendPayloadPartsresolves the canonical media alias chain (media→mediaUrl/path/filePath/fileUrl/image→mediaUrls→attachments[]) into themediaparam adapters read.message.action— never reaches that code.hydrateAttachmentParamsForActionhandles onlybufferforsendand returns early, then dispatch goes straight to the plugin.So on the gateway path the adapter received
attachmentswith nomedia, 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 readingmediahas 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.
buildSendPayloadPartsnow consumescollectSendMediaSources, and its duplicatecollectMessageAttachmentMediaHintsis deleted (runner is −57 lines).Before unification the two paths genuinely disagreed: for
{path: A, mediaUrl: B}the runner pickedBand a naive gateway resolver pickedA. One collector makes that class of bug unrepresentable.Feishu additionally fails fast on what it cannot deliver, rather than dropping it:
fileandattachment— the only two media spellings core never resolves.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 pinningfile_path.User Impact
message.actionsends instead of silently vanishing behindok:true.attachment/file, multi-media, andthread-replymedia on Feishu now error where they previously returnedok:truewithout sending. That is the reported bug, but it is a behavior change worth calling out.Evidence
Red-green on the call site —
send.test.tsfails with the resolve call removed, passes with it restored:Full suites (Node 22.22.3):
Lint/format:
oxfmt --checkclean on all changed files;check-max-lines-ratchetOK.message-action-params.tsstill trips rawoxlintmax-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:changeddelegates 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.tsalso callsdispatchChannelMessageAction, but it is reached from the runner afterbuildSendPayloadParts, 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.captionwithoutmessage— the runner folds it intomessage; the gateway does not.extraParamKeys— plugin-declared media params are resolved on the runner path only.assertMediaNotDataUrlis not applied to newly resolved values (a caller could already passmedia: "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
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.