fix(mattermost): use inbound root_id to correct non-root replyToId (closes #30977)#1456
Open
BingqingLyu wants to merge 1 commit intomainfrom
Open
fix(mattermost): use inbound root_id to correct non-root replyToId (closes #30977)#1456BingqingLyu wants to merge 1 commit intomainfrom
BingqingLyu wants to merge 1 commit intomainfrom
Conversation
…Id (openclaw#30977) When `replyToMode` is "off" for DMs, `effectiveReplyToId` is always undefined. The core reply dispatcher sets `payload.replyToId` to the inbound message's own ID (via `applyReplyThreading` / `[[reply-to:current]]`). For thread replies this ID is a non-root post, which Mattermost rejects with 400 "Invalid RootId parameter" — because `root_id` must reference the thread's actual root post. Add an `inboundRootId` parameter to `resolveMattermostReplyRootId` that carries the inbound post's `root_id`. Resolution order: 1. `threadRootId` (effectiveReplyToId from replyToMode / thread context) 2. `inboundRootId` (the inbound post's root_id — always a valid root) 3. `replyToId` (agent/directive-supplied — may be non-root; last resort) This ensures thread replies in DMs use the correct root post ID while preserving existing behaviour for top-level messages and channels with `replyToMode` enabled.
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
replyToModeis"off"for DMs,effectiveReplyToIdis alwaysundefinedpayload.replyToIdto the inbound message's own ID (viaapplyReplyThreading/[[reply-to:current]])400 Invalid RootId parameterbecauseroot_idmust reference the thread's actual root postinboundRootIdparameter toresolveMattermostReplyRootIdcarrying the inbound post'sroot_id, which is always a valid thread root when setResolution order:
threadRootId— effectiveReplyToId from replyToMode / thread contextinboundRootId— the inbound post'sroot_id(always a valid root)replyToId— agent/directive-supplied (may be non-root; last resort)Reproduction
root_id=A)root_id=A)payload.replyToId = C(non-root post)resolveMattermostReplyRootIdfalls through toreplyToId = C→ 400 Bad RequestWith this fix, step 5 resolves to
inboundRootId = A(the valid thread root).Test plan
inboundRootIdtakes priority over non-rootreplyToIdwhenthreadRootIdis absentthreadRootIdstill takes priority overinboundRootIdreplyToIdwhen both are absent (top-level message)inboundRootIdCloses openclaw#30977
🤖 Generated with Claude Code