Skip to content

fix(mattermost): use thread root_id from metadata for CRT thread replies#28192

Closed
outsourc-e wants to merge 2 commits into
NousResearch:mainfrom
outsourc-e:fix/issue-28005-mattermost-crt-root-id-v2
Closed

fix(mattermost): use thread root_id from metadata for CRT thread replies#28192
outsourc-e wants to merge 2 commits into
NousResearch:mainfrom
outsourc-e:fix/issue-28005-mattermost-crt-root-id-v2

Conversation

@outsourc-e

Copy link
Copy Markdown
Contributor

Summary

  • fix Mattermost CRT thread replies to use the root post id from metadata instead of the nested reply id
  • add focused regression coverage so CRT thread replies keep using metadata.thread_id when present

Why

The upstream PR #28012 is conceptually right but stacked with an unrelated gateway restart notification config fix. This branch keeps only the Mattermost CRT fix.

Test Plan

  • scripts/run_tests.sh tests/gateway/test_mattermost.py

Closes #28005
Supersedes #28012

colin-chang and others added 2 commits May 18, 2026 16:35
When reply_mode=thread and a user sends from inside a CRT Thread,
the previous code used reply_to (user's message ID) as root_id.
In Mattermost CRT, root_id must point to the root-level post,
not a nested reply. Using the wrong ID causes 400 Invalid RootId.

Fix: use metadata['thread_id'] (set by _thread_metadata_for_source)
which correctly contains the Thread's root message ID.

Closes NousResearch#28005
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels May 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with comprehensive #20874 which fixes Mattermost thread routing across sends, typing, media, and progress (resolving #12063, #18279). This PR is a narrower extract from #28012 (CRT fix only). Supersedes #28012.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as duplicate of #28251 by @colin-chang, which was merged via salvage PR #28354 (commit 06161c6). Both PRs fix the same Mattermost CRT root_id bug — your approach used the thread_id from metadata as a fallback; colin-chang's used an API roundtrip via _resolve_root_id() to resolve the actual root post. The API approach also covers the case where metadata doesn't carry thread_id. Thanks for the work!

@teknium1 teknium1 closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mattermost): CRT Thread replies fail with 400 Invalid RootId when using reply_to as root_id

4 participants