Skip to content

WhatsApp extension plugin sendMedia doesn't forward mediaLocalRoots (agent workspace media blocked) #33504

@odrobnik

Description

@odrobnik

Summary

extensions/whatsapp/src/channel.ts line 298: sendMedia does not destructure or forward mediaLocalRoots from the outbound context. This causes assertLocalMediaAllowed to receive undefined roots, falling back to defaults that exclude the agent workspace directory.

Result: Any media file in the agent workspace (e.g. ~/workspace/image.png) fails with LocalMediaAccessError: Local media path is not under an allowed directory when sent via WhatsApp — even though getAgentScopedMediaLocalRoots correctly includes the workspace.

Fix

- sendMedia: async ({ to, text, mediaUrl, accountId, deps, gifPlayback }) => {
+ sendMedia: async ({ to, text, mediaUrl, mediaLocalRoots, accountId, deps, gifPlayback }) => {
    const send = deps?.sendWhatsApp ?? getWhatsAppRuntime().channel.whatsapp.sendMessageWhatsApp;
    const result = await send(to, text, {
      verbose: false,
      mediaUrl,
      accountId: accountId ?? undefined,
      gifPlayback,
+     mediaLocalRoots,
    });

The core plugin at src/channels/plugins/outbound/whatsapp.ts already has the correct implementation but is unused — the extension plugin is the actual runtime adapter.

Prior Art

This is the same bug as #23140. Two fix PRs were submitted (#23148, #23272) — both were stale-bot closed without maintainer review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions