fix(mattermost): use thread root_id from metadata for CRT Thread replies#28012
Open
colin-chang wants to merge 2 commits into
Open
fix(mattermost): use thread root_id from metadata for CRT Thread replies#28012colin-chang wants to merge 2 commits into
colin-chang wants to merge 2 commits into
Conversation
…sections to PlatformConfig Setting `gateway_restart_notification: false` in config.yaml platform sections (e.g. `discord:`, `telegram:`) was silently ignored — the setting never reached the PlatformConfig object, so restart/shutdown notifications were always sent regardless of the user's preference. Root cause (two-part): 1. The shared-key bridging loop in load_gateway_config() omitted `gateway_restart_notification` from its bridge list, so the value from `discord:` YAML never entered `platforms_data`. 2. PlatformConfig.from_dict() only read the key from the top-level dict, not from `extra` where bridged values are stored. Fix: - Add `gateway_restart_notification` to the bridging loop so the YAML value propagates into `platforms_data["<plat>"].extra`. - Update PlatformConfig.from_dict() to fall back to `extra` when the top-level key is absent, matching the pattern used by other bridged settings. Regression tests added for both from_dict() extra-fallback and the end-to-end load_gateway_config() bridging path.
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
Collaborator
Contributor
|
I pulled this into a clean upstream/main worktree. The Mattermost CRT fix is good, but the branch is stacked with an unrelated gateway_restart_notification config fix. I opened a clean replacement PR with only the CRT-thread change plus focused regression coverage: #28192. |
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
Fixes a bug where Hermes replies fail with
400 Invalid RootIdwhenMATTERMOST_REPLY_MODE=threadand the user sends a message from inside an existing CRT Thread.Root Cause
gateway/platforms/mattermost.pyline 272-274 usedreply_to(the user's immediate message ID) as theroot_id. In Mattermost CRT, when replying inside an existing Thread,root_idmust point to the thread's root-level post, not a nested reply message. Using the user's own message ID — which is itself a reply — causes Mattermost to reject with 400.The correct
root_idis already available inmetadata["thread_id"], set by_thread_metadata_for_source()based onpost.root_idfrom the incoming WebSocket event.Why top-level channel messages worked
When the user sends from the main channel (not in a Thread), their message IS a root-level post. Using
reply_toasroot_idis valid in that case. The bug only manifests inside existing CRT Threads.Fix
Testing
MATTERMOST_REPLY_MODE=threadreply_towhenmetadatais None)Closes #28005