hermes-agent/scripts/whatsapp-bridge
Teknium 6fad6f1dd8
fix(whatsapp): contain and surface inbound media download failures (port nanoclaw#2895) (#59261)
Port from nanocoai/nanoclaw#2895's never-silently-drop guarantee.

Before: saveMedia() in scripts/whatsapp-bridge/bridge_helpers.js awaited
downloadMedia() with no try/catch. A failed CDN fetch (expired media URL,
transient network error — Baileys throws 'Failed to fetch stream from
https://mmg.whatsapp.net/...') rejected out of extractBridgeEvent, which
bridge.js awaits inside its messages.upsert for-loop with no per-message
guard — dropping the failed message AND every remaining message in the
same upsert batch, silently.

After:
- saveMedia catches download/write failures, records the media type, and
  logs a console.warn instead of rejecting.
- appendMediaFailureNote() (exported pure helper, mirroring the file's
  testable-helper convention) surfaces '[<type> could not be downloaded]'
  in the event body, so the agent learns media was sent rather than the
  attachment vanishing. Applied before the '[<type> received]' fallback
  so an uncaptioned failed image reads as a failure, not an arrival.

The reuploadRequest recovery half of nanoclaw#2895 is already wired in
bridge.js (downloadMediaMessage(..., { reuploadRequest:
sock.updateMediaMessage })); this ports the containment half hermes was
missing.

Tests: 3 new cases in bridge.native.test.mjs (note formatting, uncaptioned
failure containment, captioned failure note). All 5 bridge test files pass.
2026-07-05 17:21:28 -07:00
..
allowlist.js fix(whatsapp): reject strangers by default, never respond in self-chat (#8389) (#21291) 2026-05-07 06:53:04 -07:00
allowlist.test.mjs fix(whatsapp): reject strangers by default, never respond in self-chat (#8389) (#21291) 2026-05-07 06:53:04 -07:00
bridge.js fix(whatsapp): gate poll-vote events to Hermes-created polls + salvage follow-ups 2026-07-05 06:27:20 -07:00
bridge.native.test.mjs fix(whatsapp): contain and surface inbound media download failures (port nanoclaw#2895) (#59261) 2026-07-05 17:21:28 -07:00
bridge.sendqueue.test.mjs fix(whatsapp-bridge): serialize sendMessage to prevent cross-chat contamination (#33360) 2026-06-28 01:10:14 -07:00
bridge_helpers.js fix(whatsapp): contain and surface inbound media download failures (port nanoclaw#2895) (#59261) 2026-07-05 17:21:28 -07:00
outbound_ids.js fix(whatsapp-bridge): clarify FIFO outbound-id tracker semantics 2026-06-30 03:41:43 -07:00
outbound_ids.test.mjs fix(whatsapp-bridge): clarify FIFO outbound-id tracker semantics 2026-06-30 03:41:43 -07:00
owner_message_gate.js fix(whatsapp): gate owner-typed forwards on customer chatId allowlist 2026-06-30 03:41:43 -07:00
owner_message_gate.test.mjs fix(whatsapp): gate owner-typed forwards on customer chatId allowlist 2026-06-30 03:41:43 -07:00
package-lock.json Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
package.json fix(whatsapp): pin protobufjs >=7.5.5 via npm overrides to clear 3 critical vulns (#19204) 2026-05-03 05:22:30 -07:00