Skip to content

Bug: Chatwoot β†’ Cloud API audio fails with `TypeError: t.mimetype?.startsWith is not a functionΒ #2678

Description

@victorexcom

πŸ“‹ Bug Description

Environment

  • Evolution API: v2.3.7
  • Chatwoot: latest
  • Integration: WhatsApp Business Cloud API
  • Storage: IDrive E2 (S3 compatible)
  • Docker deployment

Problem

Sending an audio attachment from Chatwoot to a WhatsApp Cloud API instance fails with:

TypeError: t.mimetype?.startsWith is not a function
    at Ls.audioWhatsapp
    at ut.sendAttachment
    at ut.receiveWebhook

Text messages, images and PDFs are sent successfully. Only audio attachments are affected.

Reproduction

  1. Configure Chatwoot with Evolution API.
  2. Configure a WhatsApp Business Cloud API instance.
  3. Open a conversation.
  4. Send an audio message from the Chatwoot interface.
  5. The request fails before reaching Meta.

Comparison

Scenario A β€” audio sent directly using the Evolution API endpoint
Result: βœ… No mimetype?.startsWith exception. Evolution continues processing normally.

Scenario B β€” the exact same audio sent from Chatwoot
Result: ❌ Exception thrown immediately, before the request reaches Meta:

TypeError: t.mimetype?.startsWith is not a function

Payload comparison (anonymized)

Works β€” direct Evolution API call:

{
  "mimetype": "audio/ogg"
  // ...
}

Fails β€” via Chatwoot:

{
  "mimetype": null
  // or {}, or the actual captured value β€” TO FILL IN
}

(placeholder β€” replace with the real captured object once logged; see note below)

Expected behavior

Evolution should correctly detect or normalize the attachment MIME type received from Chatwoot before calling audioWhatsapp(). Since ?. only guards against null/undefined, a non-null, non-string mimetype (object, array, etc.) reaches .startsWith() unguarded and throws.

Additional information

This appears to affect only the Chatwoot β†’ Cloud API attachment flow. The direct Evolution API β†’ Cloud API flow works correctly.

If necessary, I can provide the complete stack trace, the Chatwoot payload, the Evolution payload, and a full comparison between both requests.

πŸ”„ Steps to Reproduce

  1. Configure Chatwoot with Evolution API.
  2. Configure a WhatsApp Business Cloud API instance.
  3. Open a conversation in Chatwoot.
  4. Send an audio message from the Chatwoot interface.
  5. Request fails with TypeError before reaching Meta:
    TypeError: t.mimetype?.startsWith is not a function
    at Ls.audioWhatsapp
    at ut.sendAttachment
    at ut.receiveWebhook

Note: sending the same audio directly via the Evolution API endpoint (bypassing Chatwoot) works fine β€” no exception.

βœ… Expected Behavior

Evolution should correctly detect or normalize the attachment MIME type received from Chatwoot before calling audioWhatsapp()

❌ Actual Behavior

TypeError: t.mimetype?.startsWith is not a function
at Ls.audioWhatsapp
at ut.sendAttachment
at ut.receiveWebhook

🌍 Environment

  • OS: [e.g. Ubuntu 20.04, Windows 10, macOS 12.0]
  • Node.js version: [e.g. 18.17.0]
  • Evolution API version: [e.g. 2.3.7]
  • Database: [e.g. PostgreSQL 14, MySQL 8.0]
  • Connection type: [e.g. Baileys, WhatsApp Business API]

πŸ“‹ Logs

πŸ“ Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions