evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Error: "TypeError: Cannot read properties of undefined (reading 'toString')" in audioWhatsapp function

Open nestordavalos opened this issue 1 year ago • 0 comments

Welcome!

  • [X] Yes, I have searched for similar issues on GitHub and found none.

What did you do?

When trying to process an audio file in WhatsApp, the following error appears in the logs:

TypeError: Cannot read properties of undefined (reading 'toString')
    at Es.audioWhatsapp (/evolution/dist/main.js:234:18155)
    at me.sendAttachment (/evolution/dist/main.js:82:10385)
    at me.receiveWebhook (/evolution/dist/main.js:84:243)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async oi.dataValidate (/evolution/dist/main.js:246:98817)
    at async /evolution/dist/main.js:246:133074

Steps to reproduce:

Execute the audioWhatsapp function with an audio file via the API. The error is thrown when the code attempts to access an undefined property that should call toString(). Expected behavior: The audio file should be processed correctly without throwing errors.

Additional details:

Possible cause: Missing validation before attempting to access the variable that is calling toString(). Review needed on line 234 of main.js to ensure the variable is not undefined before attempting to call toString().

What did you expect?

I expected the audioWhatsapp function to process the audio file without errors. Specifically, the variable being accessed should not be undefined, and the function should correctly handle or validate the data before attempting to call toString().

What did you observe instead of what you expected?

Instead of processing the audio file correctly, the application throws a TypeError, indicating that the variable is undefined and the function is attempting to call toString() on it. This causes the process to fail unexpectedly.

Screenshots/Videos

No response

Which version of the API are you using?

v2.1.2

What is your environment?

Docker

Other environment specifications

No response

If applicable, paste the log output

No response

Additional Notes

No response

nestordavalos avatar Oct 06 '24 02:10 nestordavalos