TypeError: Cannot convert undefined or null to object - createMessage method

Hello Social Plus team,
We’ve recently observed a strange error in Sentry related to our chat module:

Uncaught (in promise) TypeError: Cannot convert undefined or null to object

I’ve reviewed my code and everything appears to be correct. The error seems to originate directly from the SDK. I also checked the payload passed to createMessage, which looks like this:

{
    "data": {
        "text": "test",
        "files": [],
        "images": [],
        "videos": []
    },
    "dataType": "text",
    "subChannelId": "67a35d82129b5a78c171198e"
}

I suspect the issue might be linked to the updateSubChannelCache and shallowClone functions - @amityco/ts-sdk/src/subChannelRepository/utils/updateSubChannelCache.ts

SDK version: 6.33.0

Although creating a new chat and sending a message work correctly, we consistently see this error whenever we initiate a chat with a new message. Has anyone encountered a similar issue or knows why this might be happening?

Thank you in advance for any insights!

Hello @Radek, thank you for bringing this to our attention. Could you please confirm your application region as well?

The application region is EU

Hello @Radek , We are unable to reproduce this issue on our end. Could you kindly provide a screen recording along with step-by-step details on how to replicate the issue? This will help us conduct a more thorough investigation. Thank you.

Sure, here you go - Error Handling in Message Sending | Loom

Hey,
Do you have any news about that issue?

Hello @Radek, Our team is working on this issue, and I will provide an update soon.

1 Like

Hello @Radek ,

Could you confirm whether you are using our UIKit or implementing your own app?

If you are implementing it on your own, could you share the sequence of SDK API calls when initiating a new chat? Specifically, have you called .getMessage() before .createMessage()?

This will help us better understand the implementation and investigate further. Looking forward to your response!

Hey @SocialPlus_Support,
We implement our own app with your SDK (without any UIKit). Also here I leave the sequence of SDK API calls once I decide to create a new chat and I add 2 members to with sending a message (First I create a new chat, then I add 2 users to it, and at the end I send a message).

Sequence:

https://api.eu.amity.co/api/v3/channels/conversation
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67a32ef1f7f0d3e02f0cbf18
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67a32ef1f7f0d3e02f0cbf18
https://api.eu.amity.co/api/v4/channels/67a32ef1f7f0d3e02f0cbf18/users?channelId=67a32ef1f7f0d3e02f0cbf18&options%5Blimit%5D=100
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&options%5Blimit%5D=15
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&isDeleted=false&options%5Blimit%5D=50&dataType=image
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&isDeleted=false&options%5Blimit%5D=50&dataType=video
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&isDeleted=false&options%5Blimit%5D=50&dataType=custom
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&isDeleted=false&options%5Blimit%5D=50&dataType=file
https://api.eu.amity.co/api/v5/messages?messageFeedId=67a32ef1f7f0d3e02f0cbf18&isDeleted=false&options%5Blimit%5D=50&dataType=custom
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67a32ef1f7f0d3e02f0cbf18
https://api.eu.amity.co/api/v1/markers/sync
https://api.eu.amity.co/api/v1/markers/sync
https://api.eu.amity.co/api/v3/channels
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67b31204336365644d4436fc
https://api.eu.amity.co/api/v5/messages
https://api.eu.amity.co/api/v4/channels/67b31204336365644d4436fc/users?channelId=67b31204336365644d4436fc&options%5Blimit%5D=100
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&options%5Blimit%5D=15
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&isDeleted=false&options%5Blimit%5D=50&dataType=image
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&isDeleted=false&options%5Blimit%5D=50&dataType=video
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&isDeleted=false&options%5Blimit%5D=50&dataType=custom
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&isDeleted=false&options%5Blimit%5D=50&dataType=file
https://api.eu.amity.co/api/v5/messages?messageFeedId=67b31204336365644d4436fc&isDeleted=false&options%5Blimit%5D=50&dataType=custom
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67b31204336365644d4436fc
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67b31204336365644d4436fc
https://api.eu.amity.co/api/v3/channels?isDeleted=false&filter=member&options%5Blimit%5D=30
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67b31204336365644d4436fc&channelIds%5B%5D=67a35d82129b5a78c171198e&channelIds%5B%5D=67a35c0d7fbe523301901d9e&channelIds%5B%5D=67862e03e990a11b3ca2788d&channelIds%5B%5D=67a32ef1f7f0d3e02f0cbf18&channelIds%5B%5D=67978da80c9a4d3c08a8cb71&channelIds%5B%5D=67979cc399b2d2bc0ce1658d&channelIds%5B%5D=6797990d7961144223aabc89&channelIds%5B%5D=679798f8ddb6422488c1222b&channelIds%5B%5D=679791bd99b2d218bae0e848&channelIds%5B%5D=6781153d609c6a44052e685e&channelIds%5B%5D=6785138c7bfc85dd85ab94f4&channelIds%5B%5D=6784dc7301683298c6eb4a24
https://api.eu.amity.co/api/v4/channels/67b31204336365644d4436fc/users?channelId=67b31204336365644d4436fc&options%5Blimit%5D=100
https://api.eu.amity.co/api/v1/markers/channels?channelIds%5B%5D=67b31204336365644d4436fc
https://api.eu.amity.co/api/v1/markers/sync
https://api.eu.amity.co/api/v1/markers/messages?messageIds%5B%5D=67b312059ad5984d30e32c18
https://api.eu.amity.co/api/v1/markers/sync

Hello @Radek, thank you for providing the information. We have passed it to our team to further investigate, and will keep you posted on the updates.

Hello @Radek, could you please provide more details on the steps involved in calling these functions?

Specifically, did you call .getMessage() before .createMessage() after creating a new chat?

If possible, providing a step-by-step breakdown like the example below would help our team better understand the situation.

  1. Create a new chat
    a. ChannelRepository.createChannel()
  2. Send message
    a. MessageRepository.createMessage()
    b. MessageRepository.getMessages() => in order to show message list

Sure! Soo:

  1. User creates a new chat
    a. User selects any user from the list
    b. Once he selects one user, we trigger ChannelRepository.createChannel() with type conversation
    c. Then we trigger MessageRepository.getMessages
  2. User adds another user to group (second member)
    a. Once he adds new member, we trigger change type to community
    b. We trigger ChannelRepository.Membership.getMembers
  3. User sends a message by typing something in the input
    a. We trigger MessageRepository.createMessage
    b. Then we trigger MessageRepository.getMessages
    c. Now user sees working chat with new input
    d. The issue with console.error() appears
1 Like

Hello @Radek, thank you for providing the detail, our team is currently investigating this. We will keep you posted on the updates.

Hello @Radek, we have released a fix in version 6.35.2 Please update to this version and let us know if the issue persists.

Cool, now I don’t see that error in the console - thanks!

1 Like