Description
We are observing reproducible media-download failures for stickers in production when using downloadContentFromMessage (indirectly through command handlers).
Two recurring failure modes:
TypeError: fetch failed
Cannot derive from empty media key
This affects sticker conversion flows (sticker -> gif/png) and appears to be tied to specific incoming sticker payload shapes (some valid, some invalid/partial).
Environment
- Baileys:
github:WhiskeySockets/Baileys#v7.0.0-rc10
- Node.js:
v24.14.1
- npm:
11.11.0
- OS:
Linux 6.8.0-107-generic (Ubuntu)
- App version:
0.1.8
- Runtime model: long-running socket process (PM2)
What We Tested
1) Runtime log evidence from command path
Command !togif is correctly parsed and executed, but fails while resolving source sticker media:
2026-05-10T22:56:26Z -> TypeError: fetch failed
2026-05-10T22:57:04Z -> TypeError: fetch failed
After adding defensive handling around source resolution, the command no longer crashes and logs this warning instead:
2026-05-10T22:58:30Z -> sticker convert falhou ao resolver mídia de origem with err.message = fetch failed
So the failure is consistently happening during media retrieval, not during format conversion.
2) Database sampling (message_media) + direct URL fetch tests
We sampled recent sticker records from MySQL (message_media joined with messages) and tested URL fetchability.
Observed URL patterns:
- Fully qualified
https://mmg.whatsapp.net/... -> often downloadable (200)
https://a.whatsapp.net -> fetch failed
- Relative paths like
/m1/v/t24/... -> invalid as standalone URL for plain fetch
3) Baileys-level parity test (downloadContentFromMessage)
We replayed recent stored data_json objects through Baileys downloadContentFromMessage(media, 'sticker').
Representative outcomes:
- Success cases return valid WEBP buffers.
- Failure cases return:
fetch failed
Cannot derive from empty media key
This reproduces the same failure signatures seen in production command execution.
Reproduction (Minimal)
- Capture recent incoming sticker messages and persist media payload (
url, directPath, mediaKey, etc.)
- For each payload, call:
const stream = await downloadContentFromMessage(mediaNode, 'sticker')
- Observe that some payloads download/decrypt correctly while others fail with:
or
Cannot derive from empty media key
Expected Behavior
For sticker payloads that are valid within WhatsApp message flow, Baileys should either:
- resolve/reupload/retry media robustly, or
- return a more specific structured failure describing which field is missing/invalid (
mediaKey, URL host validity, relative URL resolution path, etc.)
Actual Behavior
For a subset of stickers, downloadContentFromMessage fails non-deterministically from application perspective due to payload shape:
- Host/URL variants that are not directly fetchable
- Payloads where media key material appears insufficient for decryption
Additional Technical Notes
- In our sample set, this is not universal failure: many stickers in same timeframe work fine.
- Failures correlate strongly with specific URL/payload variants rather than command logic.
- We currently mitigate at app level by falling back and returning user-friendly messages, but root cause remains at media retrieval/decryption boundary.
Questions for Maintainers
- Is
https://a.whatsapp.net (or relative /m1/...) expected to appear for sticker media nodes in this version?
- Is there a recommended canonical normalization path before
downloadContentFromMessage for these nodes?
- Is there a supported media-reupload retry path specifically for sticker downloads in this scenario?
- Are there known regressions around
v7.0.0-rc10 + Node 24 for sticker fetch/decrypt?
Optional: We can provide redacted payload samples
We can share several redacted data_json payloads (working vs failing) if useful for triage.
Description
We are observing reproducible media-download failures for stickers in production when using
downloadContentFromMessage(indirectly through command handlers).Two recurring failure modes:
TypeError: fetch failedCannot derive from empty media keyThis affects sticker conversion flows (
sticker -> gif/png) and appears to be tied to specific incoming sticker payload shapes (some valid, some invalid/partial).Environment
github:WhiskeySockets/Baileys#v7.0.0-rc10v24.14.111.11.0Linux 6.8.0-107-generic (Ubuntu)0.1.8What We Tested
1) Runtime log evidence from command path
Command
!togifis correctly parsed and executed, but fails while resolving source sticker media:2026-05-10T22:56:26Z->TypeError: fetch failed2026-05-10T22:57:04Z->TypeError: fetch failedAfter adding defensive handling around source resolution, the command no longer crashes and logs this warning instead:
2026-05-10T22:58:30Z->sticker convert falhou ao resolver mídia de origemwitherr.message = fetch failedSo the failure is consistently happening during media retrieval, not during format conversion.
2) Database sampling (
message_media) + direct URL fetch testsWe sampled recent sticker records from MySQL (
message_mediajoined withmessages) and tested URL fetchability.Observed URL patterns:
https://mmg.whatsapp.net/...-> often downloadable (200)https://a.whatsapp.net->fetch failed/m1/v/t24/...-> invalid as standalone URL for plain fetch3) Baileys-level parity test (
downloadContentFromMessage)We replayed recent stored
data_jsonobjects through BaileysdownloadContentFromMessage(media, 'sticker').Representative outcomes:
fetch failedCannot derive from empty media keyThis reproduces the same failure signatures seen in production command execution.
Reproduction (Minimal)
url,directPath,mediaKey, etc.)or
Expected Behavior
For sticker payloads that are valid within WhatsApp message flow, Baileys should either:
mediaKey, URL host validity, relative URL resolution path, etc.)Actual Behavior
For a subset of stickers,
downloadContentFromMessagefails non-deterministically from application perspective due to payload shape:Additional Technical Notes
Questions for Maintainers
https://a.whatsapp.net(or relative/m1/...) expected to appear for sticker media nodes in this version?downloadContentFromMessagefor these nodes?v7.0.0-rc10+ Node 24 for sticker fetch/decrypt?Optional: We can provide redacted payload samples
We can share several redacted
data_jsonpayloads (working vs failing) if useful for triage.