OpenWA icon indicating copy to clipboard operation
OpenWA copied to clipboard

[Bug]: Own-send media download failed; emitting echo without media

Open onepay-ye opened this issue 3 months ago • 7 comments

Pre-flight

  • [x] I searched existing issues and this isn't a duplicate
  • [x] I'm on the latest released version (or noted my version below)

OpenWA version

0.23.3

Deployment

Docker Compose

Database

PostgreSQL

WhatsApp engine

whatsapp-web.js

What happened?

when send media files after migration to PostgreSQL i see this error : Own-send media download failed; emitting echo without media

i need save metadata out of PostgreSQL Database with Minio: i use built-in settings

STORAGE_TYPE=s3
MINIO_BUILTIN=true
S3_ENDPOINT=http://minio:9000
S3_BUCKET=openwa

Steps to reproduce

n/a

Expected behavior

No response

Relevant logs


Environment / additional context

No response

onepay-ye avatar Aug 31 '26 21:08 onepay-ye

This is the same failure as #1466, fixed in #1480 but not yet in a release, so v0.23.3 does not carry it.

In 0.23.3 the whatsapp-web.js media path calls msg.downloadMedia() with no rejection handler, and the rejection propagates through the timeout race past the only branch that builds the omitted marker. capInboundMediaFor throws, the message_create handler catches it and logs the line you saw, and the echo goes out with no media field at all. Nothing is archived, so nothing reaches your bucket. The fix keeps the envelope (omitted: true plus the declared size) instead of dropping the field.

Worth being clear about what that changes: the degradation, not the download. The blob still will not arrive until the underlying rejection is addressed, and that reason is already in your logs, because the same warning carries an error field. Could you paste the full line? In #1466 it turned out to be a minified page-side t: t.

Separately, the configuration you posted has no S3_ACCESS_KEY_ID or S3_SECRET_ACCESS_KEY. Without them no S3 client is built and every file is written to local disk rather than to MinIO, so the bucket stays empty even when a download succeeds. The built-in MinIO uses minioadmin/minioadmin. That fallback was silent; #1511 makes it warn at startup and name both variables.

rmyndharis avatar Sep 02 '26 02:09 rmyndharis

hi @rmyndharis : Regarding these settings, I am still using them:

STORAGE_TYPE=s3 MINIO_BUILTIN=true S3_ENDPOINT=http://minio:9000/ S3_BUCKET=openwa

I will show you the log immediately after uploading an audio file, even though the audio file has already been sent.

{"timestamp":"2026-09-02T12:34:25.314Z","level":"warn","context":"WhatsAppWebJsAdapter","message":"Own-send media download failed; emitting echo without media","msgId":"true_20469898027016@lid_3EB06D2F37D85B7732EC65_out","error":"t: t","requestId":"b955e937-3b3a-433b-854c-ce028fc265aa"}

And I have a question: what is the size of the payload sent with base64 encoding? Whether for images, videos, or audio files

onepay-ye avatar Sep 02 '26 12:09 onepay-ye

Thanks for the log line. t: t is the same minified page-side rejection as #1466, and it is as far as that string can be narrowed: whatsapp-web.js runs the download inside the WhatsApp Web page, the page ships minified, so the error class and message reach us collapsed to a single letter.

Three things from your message, including a correction to what I told you last time.

Base64 payload size

One shared cap rather than a per-type table, so the number is the same for images, video and audio.

  • MEDIA_DOWNLOAD_MAX_BYTES, 50 MiB by default, measured on the decoded bytes. Over it, 413.
  • BODY_SIZE_LIMIT, 25mb by default, caps the whole JSON request.

For a base64 send the second one binds first, and that is the part worth knowing. Base64 inflates by about a third, so a 25 MB request body carries roughly 18 MiB of actual media. You reach the request-body limit well before the 50 MiB media cap, and it fails differently: the body parser rejects the request before the media cap is evaluated at all. INFLIGHT_BODY_BUDGET_BYTES (four times BODY_SIZE_LIMIT) bounds concurrent uploads in aggregate rather than one request.

That was harder to look up than it should have been, because we had it documented wrong. .env.example described the oversized-base64 rejection as a 400, docs/06 said the same on send-image and send-bulk, and only the media conversions, the status sends and the profile picture declared 413 at all. The five media sends, send-bulk and the group picture now declare it too, so the contract and the generated clients agree with what the gateway actually sends. That is on main in #1527 and reaches you with the next release.

MinIO

Add these two:

S3_ACCESS_KEY_ID=minioadmin
S3_SECRET_ACCESS_KEY=minioadmin

Your reading of the configuration was reasonable and our file was wrong. .env.example headed that block with "auto-configured if MINIO_BUILTIN=true". The auto-configuration is real, but it only runs when storage is saved from the dashboard, which writes both credentials for you. At boot, MINIO_BUILTIN=true starts the bundled MinIO container and nothing else. A hand-edited .env therefore gets the container and no keys, which is exactly what you hit. That line is corrected in the same change.

The download, and a correction

Last time I framed the fix as removing the re-download, on the grounds that the gateway already holds the payload and Baileys deliberately does not re-download. I traced it properly before changing anything, and that is not a safe change to make.

A send that supplies url rather than base64 never persists bytes, only the URL. For those the echo's download is the only copy the gateway ever holds, and there is a guard in the send path specifically to stop the URL pointer from overwriting it. Suppressing the echo download would break GET /messages/{chatId}/{messageId}/media and the outbound media archive for every URL-based send, and it would change what message.sent carries on this engine. So that approach is off the table as I described it.

Where that leaves this issue: the envelope half is fixed on main in #1480, so the echo keeps omitted: true and the declared size instead of dropping the media field, and that reaches you with the next release. The download itself still fails, and I do not yet have the cause.

One question would settle it

Only you can answer this, and it splits the two remaining explanations cleanly.

Does inbound media work on that deployment? When someone sends you an image or a voice note, does it arrive with the media payload populated, or does it come through as an omitted marker as well?

If inbound media fails too, then this is a WhatsApp Web build whose page-side changes break downloadMedia() for everything, and your own sends are simply where you noticed it first. That is a different problem with a different fix, and it would explain why the error is identical to #1466.

If inbound media works and only your own sends fail, the failure is specific to the send-side path and I have somewhere concrete to look.

Either answer is useful, and a one-line "inbound works" or "inbound fails too" is enough.

rmyndharis avatar Sep 03 '26 06:09 rmyndharis

The two problems here are both fixed on main, and neither is in 0.23.3 yet.

The own-send echo dropping its media instead of keeping the envelope was fixed in #1480: a failed inbound or own-send media download now keeps the media field with omitted: true and the declared size on both engines, so the message is archived as one that had media rather than one that never did, and hasMedia filters and automation rules match it. Baileys also now logs a failed download at warn rather than debug, so the cause is visible by default. Separately, a STORAGE_TYPE=s3 setup missing S3_ACCESS_KEY_ID or S3_SECRET_ACCESS_KEY now warns at startup and names the missing variable instead of silently writing to local disk.

I am leaving this open until a release carries those changes, and will note it here when one ships.

rmyndharis avatar Sep 04 '26 18:09 rmyndharis

Thank you @rmyndharis for your reply, dear brother:

Regarding the incoming media, they arrive normally. As for the configuration, it is already present in the file data_/.env.generated as follows:

S3_ACCESS_KEY_ID=minioadmin
S3_BUCKET=openwa
S3_ENDPOINT=http://minio:9000
S3_REGION=us-east-1
S3_SECRET_ACCESS_KEY=minioadmin
STORAGE_TYPE=s3

As for sending media via URL, it works as required. However, why does it not send when converted to base64, even though the sending size should be very small—even if it's an image, it does not exceed 60 KB?

We will wait until the version with the resolved issues is released.

onepay-ye avatar Sep 04 '26 18:09 onepay-ye

Thanks, that narrows it, and there is some good news in it.

Inbound works and URL sends work, so the failure is isolated to the own-send echo rather than to media as a whole. That rules out a WhatsApp Web build breaking downloadMedia() across the board, which was the other possibility on the table.

The base64 image is reaching the recipient. I traced the send path: the delivery call is client.sendMessage() on the whatsapp-web.js page, and it runs before and independently of the echo. The base64 body is wrapped into the outgoing media object exactly like a URL send, there is no size floor, and S3 persistence is not in the send path at all (it is fire-and-forget, after the message is already accepted by the page). So a 60 KB base64 image is sent to the recipient the same way a URL one is. Could you confirm on the recipient's device that the image actually arrives? I expect it does.

What you are seeing is the echo, not the send. When the account creates its own message, the gateway re-downloads the media to attach it to the message.sent webhook and the dashboard copy. That re-download fails page-side (t: t), and on 0.23.3 the whole media field is then dropped, so in the dashboard and the webhook it looks like nothing was sent even though the recipient has it.

That degradation is fixed on main in #1480: the echo keeps the envelope (omitted: true plus the declared size) instead of dropping the field, so a sent message stops looking empty. It reaches you in the next release. The underlying re-download still fails, which is a whatsapp-web.js page-side issue and the reason collapses to the same minified t: t, but it only ever affected the gateway's own archived copy, never the recipient's.

Leaving this open until the release that carries #1480 is out.

rmyndharis avatar Sep 05 '26 03:09 rmyndharis

v0.23.4 is out and carries both changes this was held open for: the echo keeps the media envelope with omitted: true and the declared size (#1480), and a STORAGE_TYPE=s3 setup missing its credentials now warns at startup (#1511). The page-side re-download rejection itself (t: t) is a whatsapp-web.js limitation and remains, but the message no longer presents as sent-with-nothing, and the recipient always had the media. Closing as completed; if anything still looks wrong on 0.23.4, reopen with the log line.

rmyndharis avatar Sep 06 '26 11:09 rmyndharis