Bug
When [[reply_to_current]] is used in a Mattermost thread fork session, the reply fails with:
Mattermost API 400 Bad Request: Invalid RootId parameter.
Root Cause
In extensions/mattermost/src/mattermost/monitor.ts:764, payload.replyToId takes priority over threadRootId:
replyToId: payload.replyToId || threadRootId,
When [[reply_to_current]] resolves, it sets replyToId to the inbound message ID. If that inbound message is itself a threaded reply (has a non-empty root_id), this ID gets passed as root_id to the Mattermost API. Mattermost rejects it because root_id must reference the actual root post of a thread — a post that itself has a root_id cannot be used as a thread root.
Steps to Reproduce
- Send a top-level DM message (post A)
- Bot replies in thread (post B, root_id=A)
- User replies in thread (post C, root_id=A)
- Thread fork session is created, bot replies with
[[reply_to_current]]
replyToId resolves to post C's ID
root_id is set to post C's ID → 400 Bad Request
Suggested Fix
When threadRootId is available, prefer it over payload.replyToId for the root_id field, since Mattermost does not support nested threading. Alternatively, when replyToId is set, resolve the target post's own root_id and use that if it exists.
// Instead of:
replyToId: payload.replyToId || threadRootId,
// Either:
replyToId: threadRootId || payload.replyToId,
// Or resolve the root if replyToId is itself a threaded reply
Environment
- OpenClaw running on K8s
- Mattermost Team Edition 10.11.10
- Thread fork sessions with
[[reply_to_current]]
Bug
When
[[reply_to_current]]is used in a Mattermost thread fork session, the reply fails with:Root Cause
In
extensions/mattermost/src/mattermost/monitor.ts:764,payload.replyToIdtakes priority overthreadRootId:When
[[reply_to_current]]resolves, it setsreplyToIdto the inbound message ID. If that inbound message is itself a threaded reply (has a non-emptyroot_id), this ID gets passed asroot_idto the Mattermost API. Mattermost rejects it becauseroot_idmust reference the actual root post of a thread — a post that itself has aroot_idcannot be used as a thread root.Steps to Reproduce
[[reply_to_current]]replyToIdresolves to post C's IDroot_idis set to post C's ID → 400 Bad RequestSuggested Fix
When
threadRootIdis available, prefer it overpayload.replyToIdfor theroot_idfield, since Mattermost does not support nested threading. Alternatively, whenreplyToIdis set, resolve the target post's ownroot_idand use that if it exists.Environment
[[reply_to_current]]