openclaw - 💡(How to fix) Fix [Bug] Sandbox mode: DingTalk sendMedia fails for workspace files [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51478Fetched 2026-04-08 01:10:42
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

Root Cause

In openclaw-dingtalk/src/channel.ts:

const media = await loadWebMedia(mediaUrl);

loadWebMedia calls assertLocalMediaAllowed which only allows:

  • ~/.openclaw/media/
  • ~/.openclaw/workspace/
  • ~/.openclaw/agents/
  • ~/.openclaw/sandboxes/
  • ~/.openclaw/tmp/

But sandbox workspace is at ~/.openclaw/workspace-<agent-id>/ which is NOT in the list.

Fix Action

Workaround

Currently none that works from inside the sandbox container.

Code Example

{
    mode: "all", // or "non-main"
    scope: "session",
    workspaceAccess: "rw",
  }

---

message action=send media=/workspace/image.png

---

const media = await loadWebMedia(mediaUrl);
RAW_BUFFERClick to expand / collapse

Bug: Sandbox mode - DingTalk sendMedia fails for workspace files

Problem

When using Docker sandbox with workspaceAccess: "rw", DingTalk's sendMedia fails to send images/files from the sandbox workspace path (/workspace).

The issue is that loadWebMedia runs in the Gateway process on the host, receives the container path /workspace/xxx.png, and either:

  1. Cannot resolve it to the correct host path (~/.openclaw/workspace-<agent-id>/), or
  2. The resolved path is not in the assertLocalMediaAllowed whitelist

Environment

  • OpenClaw version: latest
  • Sandbox backend: Docker
  • Sandbox config:
    {
      mode: "all", // or "non-main"
      scope: "session",
      workspaceAccess: "rw",
    }
  • Channel: DingTalk (via openclaw-dingtalk plugin)

Steps to reproduce

  1. Configure Docker sandbox with workspaceAccess: "rw"
  2. In sandbox container, save an image to /workspace/image.png
  3. Use DingTalk message tool to send the image:
    message action=send media=/workspace/image.png
  4. Image fails to send (falls back to text or errors out)

Expected behavior

loadWebMedia should correctly resolve sandbox container paths to host paths and allow files from sandbox workspaces.

Root cause

In openclaw-dingtalk/src/channel.ts:

const media = await loadWebMedia(mediaUrl);

loadWebMedia calls assertLocalMediaAllowed which only allows:

  • ~/.openclaw/media/
  • ~/.openclaw/workspace/
  • ~/.openclaw/agents/
  • ~/.openclaw/sandboxes/
  • ~/.openclaw/tmp/

But sandbox workspace is at ~/.openclaw/workspace-<agent-id>/ which is NOT in the list.

Related issues

  • #50312 - Allow configurable mediaLocalRoots for outbound media sends
  • #33251 - Slack sandbox attachments reject ~/.openclaw/workspaces paths
  • #28802 - Feishu plugin sendMediaFeishu does not include agent workspace in localRoots

Suggested fix

  1. Add ~/.openclaw/workspace-* (or dynamic agent workspace paths) to the default media local roots
  2. Or make loadWebMedia sandbox-aware, resolving container paths through the sandbox bridge

Workaround

Currently none that works from inside the sandbox container.

extent analysis

Fix Plan

To resolve the issue, we need to make loadWebMedia sandbox-aware. We can achieve this by modifying the assertLocalMediaAllowed function to include the dynamic agent workspace paths.

Step 1: Modify assertLocalMediaAllowed function

We need to update the assertLocalMediaAllowed function to include the ~/.openclaw/workspace-<agent-id>/ path. We can do this by adding a dynamic path that matches the agent workspace directory.

// In openclaw-dingtalk/src/channel.ts
const allowedMediaRoots = [
  '~/.openclaw/media/',
  '~/.openclaw/workspace/',
  '~/.openclaw/agents/',
  '~/.openclaw/sandboxes/',
  '~/.openclaw/tmp/',
  '~/.openclaw/workspace-*/', // Add this line to include dynamic agent workspace paths
];

const assertLocalMediaAllowed = (mediaPath: string) => {
  const resolvedPath = resolvePath(mediaPath);
  return allowedMediaRoots.some((root) => resolvedPath.startsWith(root));
};

Step 2: Update loadWebMedia function

We need to update the loadWebMedia function to use the modified assertLocalMediaAllowed function.

// In openclaw-dingtalk/src/channel.ts
const loadWebMedia = async (mediaUrl: string) => {
  const mediaPath = resolvePath(mediaUrl);
  if (!assertLocalMediaAllowed(mediaPath)) {
    throw new Error(`Media path not allowed: ${mediaPath}`);
  }
  // Rest of the function remains the same
};

Verification

To verify that the fix worked, you can follow these steps:

  • Configure the Docker sandbox with workspaceAccess: "rw"
  • Save an image to /workspace/image.png in the sandbox container
  • Use the DingTalk message tool to send the image: message action=send media=/workspace/image.png
  • The image should now be sent successfully

Extra Tips

  • Make sure to update the allowedMediaRoots array to include any additional paths that you want to allow.
  • Consider making the loadWebMedia function more robust by handling errors and edge cases.
  • You can also consider adding a configuration option to allow users to customize the allowedMediaRoots array.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

loadWebMedia should correctly resolve sandbox container paths to host paths and allow files from sandbox workspaces.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING