fix(hooks): pass media metadata to internal message_received hook#88740
Conversation
Forward canonical inbound media metadata to internal message_received hooks so internal hook consumers can inspect the same mediaPath, mediaUrl, mediaType, mediaPaths, mediaUrls, and mediaTypes fields already available to plugin hooks (fixed in 65e2120) and inbound_claim. The toInternalMessageReceivedContext mapper was not updated when commit 65e2120 added these fields to the plugin mapper, causing internal hooks to silently lose media metadata on received messages. Signed-off-by: Sebastien Tardif <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed May 31, 2026, 2:40 PM ET / 18:40 UTC. Summary PR surface: Source +6, Tests +9. Total +15 across 2 files. Reproducibility: yes. Source inspection shows canonical inbound contexts carry media fields and the plugin/inbound-claim mappers preserve them, while current main's internal received mapper omits them before dispatching internal hooks. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Next step before merge
Security Review detailsBest possible solution: Land this narrow mapper/test fix after the normal mergeability and CI gates run against current main. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows canonical inbound contexts carry media fields and the plugin/inbound-claim mappers preserve them, while current main's internal received mapper omits them before dispatching internal hooks. Is this the best way to solve the issue? Yes. The mapper is the single bridge into the internal AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against e76df691fe43. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +6, Tests +9. Total +15 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
Land-ready proof for PR #88740. Reviewed changed surface and sibling mapper paths: src/hooks/message-hook-mappers.ts, src/hooks/message-hook-mappers.test.ts, src/hooks/internal-hooks.ts, and src/auto-reply/reply/dispatch-from-config.ts. Local proof run on head 002a324:
GitHub proof checked before merge:
Best-fix verdict: best. This is the narrow bridge into internal message:received hook dispatch, and the PR mirrors the already-canonical media metadata fields from the plugin received hook mapper without changing runtime control flow. |
Forward canonical inbound media metadata to internal message:received hook consumers, matching the plugin received hook mapper and inbound-claim metadata path. This fixes internal hook handlers losing mediaPath, mediaUrl, mediaType, mediaPaths, mediaUrls, and mediaTypes for received messages with attachments. Verification: - node scripts/run-vitest.mjs src/hooks/message-hook-mappers.test.ts - .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main Refs: openclaw#88740 Thanks @SebTardif. Co-authored-by: Sebastien Tardif <[email protected]>
Forward canonical inbound media metadata to internal message:received hook consumers, matching the plugin received hook mapper and inbound-claim metadata path. This fixes internal hook handlers losing mediaPath, mediaUrl, mediaType, mediaPaths, mediaUrls, and mediaTypes for received messages with attachments. Verification: - node scripts/run-vitest.mjs src/hooks/message-hook-mappers.test.ts - .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main Refs: openclaw#88740 Thanks @SebTardif. Co-authored-by: Sebastien Tardif <[email protected]>
Forward canonical inbound media metadata to internal message:received hook consumers, matching the plugin received hook mapper and inbound-claim metadata path. This fixes internal hook handlers losing mediaPath, mediaUrl, mediaType, mediaPaths, mediaUrls, and mediaTypes for received messages with attachments. Verification: - node scripts/run-vitest.mjs src/hooks/message-hook-mappers.test.ts - .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main Refs: openclaw#88740 Thanks @SebTardif. Co-authored-by: Sebastien Tardif <[email protected]>
Problem
Commit 65e2120 (PR #87297) added six missing media metadata fields
(
mediaPath,mediaUrl,mediaType,mediaPaths,mediaUrls,mediaTypes) to the plugintoPluginMessageReceivedEventmapper,but the parallel internal
toInternalMessageReceivedContextmapperwas not updated.
Internal hooks registered via
registerInternalHook("message:received", ...)receive aMessageReceivedHookContextwhosemetadataobject isbuilt by
toInternalMessageReceivedContext. Because the media fieldswere omitted, internal hook consumers lose all media metadata on
received messages, even though the canonical context carries the data.
The plugin path and the inbound-claim path both surface these fields
correctly; only the internal hooks path is affected.
Fix
Add the same six media fields to the
metadataobject intoInternalMessageReceivedContext, matching the plugin mapper that wasfixed in 65e2120.
Production diff is +6 lines in
src/hooks/message-hook-mappers.ts, +8lines of test assertions in the corresponding test file.
Real behavior proof
Behavior addressed: Internal hooks
message:receivedcontext nowincludes all six media metadata fields (
mediaPath,mediaUrl,mediaType,mediaPaths,mediaUrls,mediaTypes) in its metadataobject, matching the plugin path fixed in PR #87297.
Real environment tested: macOS 15.5, Node.js v22.16.0, OpenClaw built
from source (commit 01ef169 + this patch) at
/tmp/fix-internal-hooks-media.Exact steps or command run after this patch:
Step 1: Install deps and run targeted tests
Step 2: Type-check the core project
$ pnpm tsgo:coreStep 3: Build OpenClaw from patched source
$ pnpm buildStep 4: Verify the fix is in compiled production code
Step 5: Start the patched gateway to confirm module loads cleanly
$ timeout 10 node openclaw.mjs gatewayEvidence after fix: terminal output copied below.
Vitest results (13/13 pass, including new media assertions):
Type check passes:
Compiled production code shows all six media fields in
toInternalMessageReceivedContext:Gateway starts and shuts down cleanly with patched module:
Observed result after fix: The compiled
toInternalMessageReceivedContextfunction now includes all six media metadata fields (
mediaPath,mediaUrl,mediaType,mediaPaths,mediaUrls,mediaTypes) in itsmetadatareturn object, matchingtoPluginMessageReceivedEvent. Thegateway loads the patched module cleanly. Tests confirm the fields
propagate through with correct values for both single-attachment and
multi-attachment scenarios.
What was not tested: Live message delivery through a channel provider
(WhatsApp, Telegram) with actual media attachments, because that requires
a configured provider account. The fix is a pure data-forwarding change
with no conditional logic.