waha icon indicating copy to clipboard operation
waha copied to clipboard

[NOWEB] Voice/audio messages saved as 0-byte files in S3 storage — downloadMediaMessage 'buffer' mode returns empty buffer

Open daniel-rudaev opened this issue 8 months ago • 2 comments

Description

Voice/audio messages (OGG Opus) are saved as 0-byte empty files when using NOWEB engine with S3 media storage. Images download correctly through the same pipeline.

Version

  • WAHA: 2026.2.1 (also confirmed in latest core branch source)
  • Engine: NOWEB
  • Tier: PLUS
  • Media storage: S3 (AWS, eu-central-1)

Steps to reproduce

  1. Configure WAHA with WAHA_MEDIA_STORAGE=S3 and a valid S3 bucket
  2. Start a NOWEB session
  3. Receive an image message → file saved to S3 with correct size (e.g. 143KB) ✅
  4. Receive a voice message (PTT / audio/ogg) → file saved to S3 as 0 bytes ❌

Expected behavior

Voice/audio files should be saved with their actual content, same as images.

Actual behavior

  • hasMedia: true in webhook ✅
  • media.url present, pointing to S3 ✅
  • File exists in S3 bucket ✅
  • File size: 0 bytes ❌
  • No errors in WAHA logs — the save appears successful

Analysis

The NOWEB media processor in session.noweb.core.ts calls:

return (await downloadMediaMessage(
  message,
  'buffer',   // <-- this mode
  {},
  {
    logger: this.logger,
    reuploadRequest: this.session.sock.updateMediaMessage,
  },
).finally(() => {
  content.url = url;
})) as Buffer;

The 'buffer' mode in Baileys silently returns an empty buffer for audio/voice messages without throwing an error. This is a known Baileys issue:

  • https://github.com/WhiskeySockets/Baileys/issues/681 (wrong HKDF key for audio-as-document)
  • https://github.com/openclaw/openclaw/issues/4636 (0-byte voice, fix = switch to 'stream' mode)

Images are unaffected because they go through a different decryption path in Baileys.

Suggested fix

Switch from 'buffer' to 'stream' mode and collect chunks manually:

const stream = await downloadMediaMessage(
  message,
  'stream',
  {},
  {
    logger: this.logger,
    reuploadRequest: this.session.sock.updateMediaMessage,
  },
);
const chunks = [];
for await (const chunk of stream) {
  chunks.push(chunk);
}
return Buffer.concat(chunks);

This is the fix confirmed working in openclaw/openclaw#4636.

Environment

  • OS: Linux x64 (Docker on AWS EC2)
  • Deployment: Coolify
  • S3 config: WAHA_S3_PROXY_FILES=false, WHATSAPP_FILES_LIFETIME=86400
  • No WHATSAPP_FILES_MIMETYPES restriction (all types enabled)
  • WHATSAPP_DOWNLOAD_MEDIA not set (defaults true)

daniel-rudaev avatar Apr 02 '26 11:04 daniel-rudaev

Opened a PR with the fix: #1997. Tested in production — voice messages now download correctly (58KB instead of 0 bytes).

daniel-rudaev avatar Apr 02 '26 12:04 daniel-rudaev

2026.4.1 - NOWEB - use stream mode for media download to fix 0-byte audio/voice files - #1996

patron:PRO

devlikepro avatar Apr 15 '26 07:04 devlikepro