fix(gateway): use correct root_id for Mattermost thread replies#6617
Open
nericervin wants to merge 1 commit into
Open
fix(gateway): use correct root_id for Mattermost thread replies#6617nericervin wants to merge 1 commit into
nericervin wants to merge 1 commit into
Conversation
When replying inside an existing Mattermost thread, Hermes was using event.message_id (the individual reply post) as root_id. Mattermost requires root_id to be the first post that started the thread, so replies to threaded messages failed with root_id.app_error (400). Now prefer metadata.thread_id (the actual thread root) over reply_to when available. This correctly handles both cases: - New thread: reply_to (user's message) becomes the thread root - Existing thread: metadata.thread_id points to the original root
19 tasks
This was referenced Apr 21, 2026
Collaborator
1 similar comment
Collaborator
|
Also related to #18279 (only one paralell threaded mattermost conversation possible) |
This was referenced May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Mattermost thread replies failing with
root_id.app_error(400) whenMATTERMOST_REPLY_MODE=threadis enabled.Problem
When a user messages the bot inside an existing Mattermost thread,
reply_tois set toevent.message_id— the ID of the individual reply post. But Mattermost requiresroot_idto be the first post that started the thread. Using a non-root post ID causes:{"id":"api.post.create_post.root_id.app_error","message":"Invalid RootId parameter","status_code":400}Fix
In
send(),_download_and_post_file(), and_send_local_file(): prefermetadata.thread_id(whichbase.pyalready populates fromevent.source.thread_id, i.e. the actual thread root) overreply_to. This handles both cases:thread_idin metadata → falls back toreply_to, creating a new thread under the user's messagethread_idis the root post → reply lands in the correct threadTest plan
MATTERMOST_REPLY_MODE=thread→ bot creates a new thread (reply under user's message)