Bug: Chatwoot → Cloud API audio fails with `TypeError: t.mimetype?.startsWith is not a function
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- api
Research direction
Trace the audio path named in the stack trace, starting at audioWhatsapp and following sendAttachment and receiveWebhook, then compare it with the direct Evolution API path. Use a real captured Chatwoot payload because the issue's mimetype examples are placeholders; done means the audio request no longer throws before reaching Meta while direct sending still works.
Written by the indexing model from the issue text.
Description
📋 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
- Configure Chatwoot with Evolution API.
- Configure a WhatsApp Business Cloud API instance.
- Open a conversation.
- Send an audio message from the Chatwoot interface.
- 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
- Configure Chatwoot with Evolution API.
- Configure a WhatsApp Business Cloud API instance.
- Open a conversation in Chatwoot.
- Send an audio message from the Chatwoot interface.
- 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
- Dominant language
- TypeScript
- Stars
- 9.6k
- Forks
- 7.3k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from evolution-foundation/evolution-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
evolution-foundation/evolution-api#2700 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
All issues in evolution-foundation/evolution-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/claude-code#96687 ·
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
AOSSIE-Org/DebateAI#582 · 2 comments ·