Skip to content

Audio files (.ogg) incorrectly detected as text/plain, causing garbled output #6869

Description

@tg5zbbpt77-dev

OpenClaw Bug Report: Audio Files Incorrectly Detected as text/plain
Summary
When receiving voice messages (.ogg audio files) from Telegram, OpenClaw incorrectly detects them as mime="text/plain" and attempts to extract their binary content as text, resulting in massive amounts of garbled characters being displayed in the chat.

Environment
OpenClaw Version: 2026.1.30
OS: macOS 26.2 (arm64)
Node: v25.5.0
Channel: Telegram
Model: anthropic/claude-sonnet-4-20250514
Steps to Reproduce
Configure OpenClaw with Telegram channel
Send a voice message (audio/ogg file) to the bot via Telegram
Observe the message content in the chat
Expected Behavior
Voice message should be downloaded
Whisper should transcribe the audio
Only the transcription text should be displayed
No binary content should be shown
Actual Behavior
The message displays:

[media attached: /path/to/file.ogg (audio/ogg; codecs=opus)]
media:audio [MASSIVE GARBLED BINARY DATA]
The binary audio data is being read and displayed as text, creating thousands of characters of garbage.

Root Cause Analysis
Telegram downloads the .ogg audio file to /Users/xxx/.openclaw/media/inbound/
The file is passed to extractFileBlocks() in media-understanding/apply.js
MIME detection incorrectly identifies the .ogg file as text/plain
The code then reads the binary audio data and attempts to display it as text
Code Location
File: /opt/homebrew/lib/node_modules/openclaw/dist/media-understanding/apply.js

The issue appears to be in the MIME detection logic:

const textLike = Boolean(utf16Charset) || looksLikeUtf8Text(bufferResult?.buffer);
The looksLikeUtf8Text() function incorrectly identifies binary audio data as text.

Attempted Workarounds
We tried several configuration approaches:

allowedMimes: [] - Didn't work because code auto-adds text/* types
maxBytes: 1 - Blocked audio files entirely (prevented transcription)
allowedMimes: ["application/x-openclaw-disabled"] - Still didn't prevent the issue
None of these workarounds successfully prevented the garbled output while maintaining audio transcription functionality.

Suggested Fix
Improve MIME detection: Audio files (especially .ogg, .mp3, .wav, .m4a) should never be detected as text/plain
Add file extension check: Before attempting text extraction, verify the file extension is not an audio/video format
Skip binary files: Add a more robust binary file detection that checks for audio/video magic bytes
Proposed Code Change
In extractFileBlocks(), add an early check:

const audioExtensions = ['.ogg', '.mp3', '.wav', '.m4a', '.opus'];
const ext = path.extname(nameHint ?? '').toLowerCase();
if (audioExtensions.includes(ext)) {
continue; // Skip audio files from text extraction
}
Impact
Severity: Medium-High
User Experience: Very poor - chat becomes unreadable with thousands of garbled characters
Workaround: None that maintains full functionality
Affected Users: Anyone using Telegram voice messages with OpenClaw
Additional Notes
Whisper transcription works correctly
The audio file is properly downloaded
The issue is purely in the text extraction/display logic
This affects all audio formats that might be misdetected as text
Logs
The message shows:

This confirms the MIME type is being incorrectly set to text/plain for an .ogg audio file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions