openclaw - ✅(Solved) Fix Mattermost: Invalid RootId should fallback to channel post instead of failing silently [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#56295Fetched 2026-04-08 01:42:40
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Error Message

[INFO] mattermost connected as @steffclaw
[ERROR] mattermost final reply failed: Error: Mattermost API 400 Bad Request: Invalid RootId parameter.

Fix Action

Fixed

PR fix notes

PR #56305: fix(mattermost): fallback to channel post when RootId is stale (invalid)

Description (problem / solution / changelog)

Summary

After a gateway restart, Mattermost bot sessions retain stale RootId references from previous thread replies. When the bot tries to reply, the Mattermost API returns:

400 Bad Request: Invalid RootId parameter.

This causes the message to fail silently with no user-visible response.

Fix

In sendMessageMattermost(), when posting with a replyToId (RootId) fails with an "Invalid RootId" or 400 error, the code now catches the failure and retries the post without rootId, posting as a regular channel message instead.

Changes

  • extensions/mattermost/src/mattermost/send.ts: Added try/catch around createMattermostPost with replyToId. On Invalid RootId error, retries the same post without rootId.
  • Also added type MattermostPost import since the new code references it explicitly.

Testing

  1. Set up Mattermost channel with gateway
  2. Restart the gateway
  3. Send a message to the bot — it should respond instead of failing silently
  4. Normal thread replies (valid RootId) should continue to work normally

Related Issue

Fixes #56295

Changed files

  • extensions/mattermost/src/mattermost/send.ts (modified, +40/-7)

Code Example

mattermost final reply failed: Error: Mattermost API 400 Bad Request: Invalid RootId parameter.

---

[INFO] mattermost connected as @steffclaw
[ERROR] mattermost final reply failed: Error: Mattermost API 400 Bad Request: Invalid RootId parameter.
RAW_BUFFERClick to expand / collapse

Problem

When the OpenClaw Gateway restarts, Mattermost sessions may retain stale RootId references from previous thread replies. When the bot then tries to respond, it attempts to post as a thread reply using the old RootId, which no longer exists in Mattermost.

This causes the reply to silently fail with:

mattermost final reply failed: Error: Mattermost API 400 Bad Request: Invalid RootId parameter.

The user sees no response at all — the bot appears dead.

Expected Behavior

When the Mattermost API returns 400 Bad Request: Invalid RootId parameter, the gateway should:

  1. Retry without root_id — post as a normal channel message instead of a thread reply
  2. Clear the stale RootId from the session state so subsequent replies don't hit the same error
  3. Optionally log a warning that a thread reference was stale

Steps to Reproduce

  1. Have an active Mattermost DM session with the bot
  2. Restart the OpenClaw gateway (openclaw gateway restart)
  3. Send a message to the bot in the same DM
  4. Bot connects successfully (mattermost connected as @botname) but replies fail silently

Logs

[INFO] mattermost connected as @steffclaw
[ERROR] mattermost final reply failed: Error: Mattermost API 400 Bad Request: Invalid RootId parameter.

Environment

  • OpenClaw version: 2026.3.24 (cff6dc9)
  • Mattermost: self-hosted
  • Config: dmPolicy: "open", chatmode: "onmessage", groupPolicy: "open"

Suggested Fix

In the Mattermost channel plugin reply handler, wrap the post call in a try/catch. If the error matches Invalid RootId, retry the post without root_id and clear the cached thread reference from the session.

This is likely a ~5 line fix in the reply path.

extent analysis

Fix Plan

To resolve the issue, we need to modify the Mattermost channel plugin reply handler. Here are the steps:

  • Wrap the post call in a try/catch block to catch the Invalid RootId error.
  • If the error occurs, retry the post without root_id and clear the cached thread reference from the session.
  • Optionally log a warning that a thread reference was stale.

Example Code

try {
  // Original post call with root_id
  const response = await mattermostClient.postMessage({
    channel_id: channelId,
    root_id: rootId,
    message: message,
  });
} catch (error) {
  if (error.message.includes('Invalid RootId parameter')) {
    // Retry post without root_id and clear cached thread reference
    const response = await mattermostClient.postMessage({
      channel_id: channelId,
      message: message,
    });
    // Clear stale RootId from session state
    sessionState.rootId = null;
    // Optionally log a warning
    console.warn('Stale thread reference detected and cleared');
  } else {
    throw error;
  }
}

Verification

To verify the fix, follow these steps:

  • Restart the OpenClaw gateway.
  • Send a message to the bot in the same DM.
  • Verify that the bot responds successfully without any errors.
  • Check the logs for any warnings about stale thread references.

Extra Tips

  • Make sure to handle any potential errors that may occur during the retry process.
  • Consider adding additional logging to track the number of stale thread references encountered.
  • Review the Mattermost API documentation to ensure that the retry approach is in line with their recommended error handling practices.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Mattermost: Invalid RootId should fallback to channel post instead of failing silently [1 pull requests, 1 participants]