openclaw - 💡(How to fix) Fix Telegram media attachment crashes all providers: null bytes in spawn args [3 comments, 3 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#49973Fetched 2026-04-08 01:00:38
View on GitHub
Comments
3
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×3

When a Telegram message includes a media attachment (e.g., a PDF document), the gateway crashes with ERR_INVALID_ARG_VALUE because the [media attached: /path/...] string passed to child_process.spawn() contains null bytes. All three fallback providers fail in sequence, and the user receives no reply.

Error Message

Error Log

[process/supervisor] spawn failed: ... (same error for sonnet) [process/supervisor] spawn failed: ... (same error for codex-cli) Note: the error alternates between args[7] (claude-cli) and args[5] (codex-cli), suggesting the null byte is in the media path string itself, not in a provider-specific argument.

Root Cause

  • The files on disk have clean filenames (verified with xxd) — no null bytes present
  • The null byte is introduced somewhere during the construction of the [media attached: ...] string that gets passed as a CLI argument
  • Node.js correctly rejects strings with null bytes in child_process.spawn() arguments (security measure since Node 20+)

Fix Action

Workaround

Sending the message without the attachment works fine. The issue only occurs when a media file is attached.

Code Example

[process/supervisor] spawn failed: runId=<redacted> reason=TypeError [ERR_INVALID_ARG_VALUE]:
  The argument 'args[7]' must be a string without null bytes.
  Received '[media attached: <path>/<cyrillic_filename>---...'

[model-fallback/decision] decision=candidate_failed requested=claude-cli/opus candidate=claude-cli/opus next=claude-cli/sonnet
[process/supervisor] spawn failed: ... (same error for sonnet)
[model-fallback/decision] decision=candidate_failed requested=claude-cli/opus candidate=claude-cli/sonnet next=codex-cli/gpt-5.4
[process/supervisor] spawn failed: ... (same error for codex-cli)

Embedded agent failed before reply: The argument 'args[5]' must be a string without null bytes.

---

// before passing to spawn args
mediaString = mediaString.replace(/\0/g, '')
RAW_BUFFERClick to expand / collapse

Description

When a Telegram message includes a media attachment (e.g., a PDF document), the gateway crashes with ERR_INVALID_ARG_VALUE because the [media attached: /path/...] string passed to child_process.spawn() contains null bytes. All three fallback providers fail in sequence, and the user receives no reply.

Steps to Reproduce

  1. Send a message to the Telegram bot with an attached document (tested with a PDF with Cyrillic characters in the filename)
  2. The gateway receives the message and attempts to spawn a CLI process
  3. All providers fail with TypeError [ERR_INVALID_ARG_VALUE]

Error Log

[process/supervisor] spawn failed: runId=<redacted> reason=TypeError [ERR_INVALID_ARG_VALUE]:
  The argument 'args[7]' must be a string without null bytes.
  Received '[media attached: <path>/<cyrillic_filename>---...'

[model-fallback/decision] decision=candidate_failed requested=claude-cli/opus candidate=claude-cli/opus next=claude-cli/sonnet
[process/supervisor] spawn failed: ... (same error for sonnet)
[model-fallback/decision] decision=candidate_failed requested=claude-cli/opus candidate=claude-cli/sonnet next=codex-cli/gpt-5.4
[process/supervisor] spawn failed: ... (same error for codex-cli)

Embedded agent failed before reply: The argument 'args[5]' must be a string without null bytes.

Note: the error alternates between args[7] (claude-cli) and args[5] (codex-cli), suggesting the null byte is in the media path string itself, not in a provider-specific argument.

Analysis

  • The files on disk have clean filenames (verified with xxd) — no null bytes present
  • The null byte is introduced somewhere during the construction of the [media attached: ...] string that gets passed as a CLI argument
  • Node.js correctly rejects strings with null bytes in child_process.spawn() arguments (security measure since Node 20+)

Suggested Fix

Sanitize the media path string before passing it to spawn() args in process/supervisor:

// before passing to spawn args
mediaString = mediaString.replace(/\0/g, '')

Or better yet, investigate where the null byte is introduced during media path construction from the Telegram message payload.

Environment

  • Openclaw version: 2026.3.13
  • Node.js: v24.6.0
  • OS: macOS (Darwin 25.3.0)
  • Telegram provider: (custom bot)
  • Filename charset: Cyrillic (UTF-8)

Workaround

Sending the message without the attachment works fine. The issue only occurs when a media file is attached.

extent analysis

Fix Plan

To resolve the issue, we need to sanitize the media path string before passing it to child_process.spawn() arguments. Here are the steps:

  • Identify the location where the media path string is constructed and passed to spawn() args in process/supervisor.
  • Modify the code to remove null bytes from the media path string using the replace() method:
mediaString = mediaString.replace(/\0/g, '')
  • Alternatively, investigate where the null byte is introduced during media path construction from the Telegram message payload and fix the root cause.

Example code snippet:

const mediaPath = '[media attached: /path/to/media/file]';
const sanitizedMediaPath = mediaPath.replace(/\0/g, '');
const spawnArgs = [...]; // other spawn args
spawnArgs.push(sanitizedMediaPath);
child_process.spawn('command', spawnArgs, { /* options */ });

Verification

To verify the fix, send a Telegram message with a media attachment (e.g., a PDF document) and check if the gateway crashes with ERR_INVALID_ARG_VALUE. If the issue is resolved, the gateway should process the message without errors.

Extra Tips

  • Make sure to test the fix with different types of media attachments and filenames to ensure the issue is fully resolved.
  • Consider adding additional logging or debugging statements to help identify where the null byte is introduced during media path construction.
  • If the issue persists, investigate other potential causes, such as encoding or decoding issues when processing the Telegram message payload.

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 Telegram media attachment crashes all providers: null bytes in spawn args [3 comments, 3 participants]