openclaw - 💡(How to fix) Fix [Bug] openclaw-weixin: MEDIA sends duplicate file content and renames files to UUID [1 participants]

Official PRs (…)
ON THIS PAGE

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#68771Fetched 2026-04-19 15:07:47
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Root Cause

Traced in buildSavedMediaId function:

javascript function buildSavedMediaId(params) { if (!params.originalFilename) return params.ext ? `` + params.baseId + params.ext : params.baseId; const base = path.parse(params.originalFilename).name; const sanitized = sanitizeFilename(base); return sanitized ? sanitized + "---" + params.baseId + params.ext : params.baseId + params.ext; }

When saveMediaSource handles local files, originalFilename is not passed in. This causes the function to fall into the !params.originalFilename branch, generating a pure UUID filename.

In sendFileMessageWeixin, fileName is derived from path.basename(filePath) where filePath is already the UUID-formatted storage path - so the UUID propagates to the WeChat message.

RAW_BUFFERClick to expand / collapse

Bug Description

When sending multiple files via MEDIA: tag through the openclaw-weixin channel, two issues occur:

  1. All MEDIA lines send the same file content - regardless of different file paths specified, only the first file's content is delivered for all attachments
  2. Filenames become UUIDs - e.g. b3b58b5b-d652-4e99-a222-8646d572c41d.pdf instead of the original filename like ????.pdf

Root Cause

Traced in buildSavedMediaId function:

javascript function buildSavedMediaId(params) { if (!params.originalFilename) return params.ext ? `` + params.baseId + params.ext : params.baseId; const base = path.parse(params.originalFilename).name; const sanitized = sanitizeFilename(base); return sanitized ? sanitized + "---" + params.baseId + params.ext : params.baseId + params.ext; }

When saveMediaSource handles local files, originalFilename is not passed in. This causes the function to fall into the !params.originalFilename branch, generating a pure UUID filename.

In sendFileMessageWeixin, fileName is derived from path.basename(filePath) where filePath is already the UUID-formatted storage path - so the UUID propagates to the WeChat message.

Reproduction Steps

  1. Use an agent with openclaw-weixin channel
  2. Send two or more different PDF files via MEDIA: in a single response, e.g.: MEDIA:C:\path\to\file1.pdf MEDIA:C:\path\to\file2.pdf
  3. Both arrive on WeChat with the same content (first file) and UUID filenames like b3b58b5b-d652-4e99-a222-8646d572c41d.pdf

Expected Behavior

Each file should be sent with its correct content and original filename preserved.

Environment

  • OpenClaw version: 2026.4.14
  • Channel: openclaw-weixin
  • OS: Windows 10

extent analysis

TL;DR

Passing the originalFilename parameter to the buildSavedMediaId function should resolve the issue of UUID filenames and duplicate file content.

Guidance

  • Verify that the originalFilename is being passed correctly when handling local files in the saveMediaSource function.
  • Update the buildSavedMediaId function to handle cases where originalFilename is not provided, potentially by throwing an error or using a default value.
  • In the sendFileMessageWeixin function, ensure that the fileName is derived from the original file path, not the UUID-formatted storage path.
  • Test the changes by sending multiple files via the MEDIA: tag and verifying that each file arrives with its correct content and original filename.

Example

function buildSavedMediaId(params) {
    if (!params.originalFilename) {
        throw new Error("originalFilename is required");
    }
    const base = path.parse(params.originalFilename).name;
    const sanitized = sanitizeFilename(base);
    return sanitized ? sanitized + "---" + params.baseId + params.ext : params.baseId + params.ext;
}

Notes

The provided code snippet and reproduction steps suggest that the issue is specific to the openclaw-weixin channel and the buildSavedMediaId function. However, without more information about the saveMediaSource and sendFileMessageWeixin functions, it is difficult to provide a comprehensive solution.

Recommendation

Apply a workaround by modifying the buildSavedMediaId function to throw an error when originalFilename is not provided, as shown in the example code snippet. This will help identify and fix the root cause of the issue.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug] openclaw-weixin: MEDIA sends duplicate file content and renames files to UUID [1 participants]