Skip to content

fix(webjs): handle null chat in typing and seen endpoints#1979

Open
saschabuehrle wants to merge 1 commit intodevlikeapro:corefrom
saschabuehrle:fix/webjs-chat-null-check-1970
Open

fix(webjs): handle null chat in typing and seen endpoints#1979
saschabuehrle wants to merge 1 commit intodevlikeapro:corefrom
saschabuehrle:fix/webjs-chat-null-check-1970

Conversation

@saschabuehrle
Copy link

Bug

#1970POST /api/startTyping returns a 500 Internal Server Error with TypeError: Cannot read properties of undefined (reading 'sendStateTyping') when the target number does not have WhatsApp.

Fix

Added null checks after getChatById() in the WEBJS engine's startTyping, stopTyping, and sendSeen methods. When the chat object is not found (e.g. the number has no WhatsApp account), these endpoints now throw a NotFoundException with a descriptive message instead of crashing with an unhandled TypeError.

The same pattern is already used elsewhere in the codebase (e.g. session manager's NotFoundException).

Testing

Verified that the fix correctly guards all three affected methods. NestJS maps NotFoundException to a 404 HTTP response, giving callers a clear signal that the chat does not exist rather than an opaque 500 error.

Happy to address any feedback.

Greetings, saschabuehrle

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.

1 participant