-
-
Notifications
You must be signed in to change notification settings - Fork 52.6k
Closed
Description
name: 🐛 Bug Report
about: Create a report to help us improve
title: "[Feishu] File upload fails with Chinese/special characters in filename"
labels: bug, feishu, file-upload
🐛 Bug Description
When sending files via Feishu channel with Chinese characters or special characters (e.g., em dash —, spaces, brackets) in the filename, the file appears as a text link instead of a downloadable attachment. Users cannot download or preview the file.
🔄 Reproduction Steps
-
Create a file with Chinese/special characters in filename:
echo "test" > "测试文件—特殊字符(2026-03-02).md"
-
Send via Feishu channel:
openclaw message send \ --target "ou_xxx" \ --channel "feishu" \ --filePath "/path/to/测试文件—特殊字符(2026-03-02).md"
-
Observe in Feishu:
- ❌ File appears as text link (underlined path)
- ❌ Cannot download
- ❌ Cannot preview
✅ Expected Behavior
File should be sent as a proper attachment with:
- ✅ Downloadable file card
- ✅ Preview support
- ✅ Original filename preserved
📊 Actual Behavior
- File sent as text link instead of attachment
- Filename visible but not clickable
- No download option available
🔍 Root Cause Analysis
The issue is in /extensions/feishu/src/media.ts → uploadFileFeishu() function.
Current code (line ~213):
const response = await client.im.file.create({
data: {
file_type: fileType,
file_name: fileName, // ❌ Direct pass, no encoding
file: fileData as any,
},
});Problem:
- HTTP multipart/form-data follows RFC2388 which requires 7bit ASCII encoding for headers
- Chinese characters and special characters (e.g.,
—U+2014 em dash) exceed this range - Feishu API receives unencoded filename and treats it as text
Fix (tested and working):
// URL encode filename to handle Chinese characters and special characters
// RFC5987 encoding for multipart/form-data compatibility
const safeFileName = encodeURIComponent(fileName)
.replace(/'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29");
const response = await client.im.file.create({
data: {
file_type: fileType,
file_name: safeFileName, // ✅ URL encoded
file: fileData as any,
},
});🧪 Test Results
| Test File | Before Fix | After Fix |
|---|---|---|
上下文恢复系统 - 使用指南.md |
❌ Text link | ✅ File attachment |
上下文恢复系统 - 原理详解.md |
❌ Text link | ✅ File attachment |
测试文件—特殊字符(2026-03-02).md |
❌ Text link | ✅ File attachment |
📋 Environment
- OpenClaw Version: 2026.2.26
- Node Version: 25.5.0
- OS: Darwin 25.3.0 (arm64)
- Channel: Feishu
- Plugin:
/extensions/feishu/src/media.ts
📎 Logs
[feishu] sendMediaFeishu failed: Error: Local file not found: /tmp/上下文恢复系统 - 使用指南.md
at sendMediaFeishu (/Users/zane/.openclaw/extensions/feishu/src/media.ts:497:15)
💡 Suggested Fix
File: /extensions/feishu/src/media.ts
Function: uploadFileFeishu()
Line: ~210-215 (before client.im.file.create())
Add filename URL encoding:
// URL encode filename to handle Chinese characters and special characters
// RFC5987 encoding for multipart/form-data compatibility
const safeFileName = encodeURIComponent(fileName)
.replace(/'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29");🎯 Impact
- Severity: High (blocks file sharing for non-English users)
- Frequency: Every file with non-ASCII filename
- Workaround: Manual filename sanitization (replace special characters)
- Users Affected: All Feishu users with Chinese/special character filenames
📸 Screenshots
[Attach screenshots showing:
- File sent as text link (before fix)
- File sent as attachment (after fix)
- Download/preview working (after fix)
]
✅ Additional Context
- This fix has been tested and verified working in production
- Temporary workaround: Replace special characters with underscores
- Permanent fix: Add URL encoding in
uploadFileFeishu()function - Related: RFC2388 multipart/form-data encoding standards
Checklist:
- I am using the latest OpenClaw version
- I have searched the existing issues and this is a new bug
- I have included reproduction steps
- I have included expected vs actual behavior
- I have included environment information
- I have included logs
- I have proposed a fix (optional)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels