Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent TypeError when accessing 'cachedGroupMetadata' in sendMe… #1110

Closed
wants to merge 1 commit into from

Conversation

tiagomatrixd
Copy link

This PR fixes a TypeError that occurred when trying to check for 'cachedGroupMetadata' in the 'sendMessage' function options.

The error was caused by attempting to use the 'in' operator on an undefined or null value. This fix adds a type check to ensure 'options' is an object before using the 'in' operator.

Changes:

  • Add a type check for 'options' to avoid errors when 'options' is undefined.

Why:

  • This prevents crashes and unexpected behavior when 'sendMessage' is called with invalid options.

@whiskeysockets-bot
Copy link
Contributor

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@tiagomatrixd/Baileys#master
# YARN v2
yarn add @whiskeysockets/baileys@tiagomatrixd/Baileys#master

Copy link
Collaborator

@purpshell purpshell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options variable is initialized by default as an empty object, that's what needs to be fixed in this case instead of adding more and more checks to an if statement. This is a deprecation warning that would be removed in the next few releases anyways

@purpshell purpshell added this to the 6.7.14 milestone Feb 24, 2025
@purpshell purpshell closed this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants