# Wrong message ID when message is added

**URL:** <https://community.sendbird.com/t/wrong-message-id-when-message-is-added/9465>\
**Category:** Flutter\
**Tags:** message\
**Created:** [April 29, 2024, 2:44pm UTC](https://community.sendbird.com/t/wrong-message-id-when-message-is-added/9465 "2024-04-29T14:44:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![System\_Yumi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/system_yumi/32/5140_2.png) [@System\_Yumi](https://community.sendbird.com/u/System_Yumi)\
**Post date:** [April 29, 2024, 2:44pm UTC](https://community.sendbird.com/t/wrong-message-id-when-message-is-added/9465/1 "2024-04-29T14:44:31Z")

</div>

**[Problem/Question]**  
My message ID is wrong when adding a message. LID on creation is not the same as on update.

* * *

// If problem, please fill out the below. If question, please delete.  
**[SDK Version]**  
sendbird\_chat\_sdk: 4.2.10

**[Reproduction Steps]**  
1/ Add MessageCollectionHandler  
2/ Check message ID in onMessagesAdded  
3/ Check message ID in onMessagesUpdated  
4/ IDs are not the same for the same message

**[Frequency]**  
Always

**[Current impact]**  
Very strong

---

<div class="post-metadata">

**Author:** ![chris-sendbird](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chris-sendbird/32/677_2.png) [@chris-sendbird](https://community.sendbird.com/u/chris-sendbird)\
**Post date:** [April 29, 2024, 4:35pm UTC](https://community.sendbird.com/t/wrong-message-id-when-message-is-added/9465/2 "2024-04-29T16:35:39Z")

</div>

The `MessageCollection` would give a pending message to `onMessagesAdded` where every pending message has a message ID of zero. Then when the message is sent successfully or failed sending, it gives an event `onMessagesUpdated` to update the message. In that case the message ID is set to the actual ID if succeeded. (And stays zero if it fails)

It’s designed by nature that a pending message is to preview the message before being sent, then updated to a succeeded message. If you’re rendering messages with a unique key, you can refer to `requestId` instead (succeeded messages also have it). You can check the message status with `sendingStatus` property in a message.

---

<div class="post-metadata">

**Author:** ![System\_Yumi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/system_yumi/32/5140_2.png) [@System\_Yumi](https://community.sendbird.com/u/System_Yumi)\
**Post date:** [April 29, 2024, 7:17pm UTC](https://community.sendbird.com/t/wrong-message-id-when-message-is-added/9465/3 "2024-04-29T19:17:31Z")

</div>

Hello Chris,  
Thank you, this is exactly what I was looking for 🙂  
Have a nice day,
