Skip to content

Mattermost: Invalid RootId when reply_to_current targets a threaded reply #30977

Description

@hnykda

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

  1. Send a top-level DM message (post A)
  2. Bot replies in thread (post B, root_id=A)
  3. User replies in thread (post C, root_id=A)
  4. Thread fork session is created, bot replies with [[reply_to_current]]
  5. replyToId resolves to post C's ID
  6. 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]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions