fix: Slack thread routing — parse channel_id:thread_ts in send_message target - #21486
Closed
dirtyren wants to merge 1 commit into
Closed
fix: Slack thread routing — parse channel_id:thread_ts in send_message target#21486dirtyren wants to merge 1 commit into
dirtyren wants to merge 1 commit into
Conversation
…e target
When send_message is called with target='slack:CHANNEL_ID:THREAD_TS',
_parse_target_ref failed to match the colon-separated format, falling
back to home channel instead. Two bugs:
1. _SLACK_TARGET_RE only matched bare channel IDs (no :thread_ts).
Added _SLACK_THREAD_TARGET_RE = r'([CGD][A-Z0-9]{8,}):([\d.]+)'
and try it first before the bare-channel regex.
2. _send_slack() had no thread_id parameter, so even if parsing worked,
the thread_ts was never sent to Slack's chat.postMessage API.
Added thread_id=None param and inject payload['thread_ts'] when set.
3. _send_to_platform() was calling _send_slack() without thread_id.
Now passes thread_id=thread_id.
Reproducer: send_message(target='slack:C0B0GV4FKK7:1778181769.602679')
was silently routing to home channel C0ATFHY907L.
Collaborator
This was referenced May 12, 2026
Contributor
|
This appears to be implemented on current Evidence:
|
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.
Problem
send_message(target='slack:C0B0GV4FKK7:1778181769.602679')was silently routing to the home channel (C0ATFHY907L) instead of channelC0B0GV4FKK7in the specified thread.Root Cause
Three separate bugs in
tools/send_message_tool.py:Bug 1 —
_parse_target_refregex miss (primary)_SLACK_TARGET_RE = r'^\s*([CGD][A-Z0-9]{8,})\s*$'only matches bare channel IDs.When
target_ref = "C0B0GV4FKK7:1778181769.602679", the regex didn't match → returned(None, None, False)→ fell through to channel-name resolution → fell back to home channel.Bug 2 —
_send_slack()missingthread_idparamEven if parsing had worked,
_send_slack()had nothread_idparameter and never setthread_tsin the Slack API payload.Bug 3 —
_send_to_platform()not forwardingthread_idThe dispatch call
await _send_slack(pconfig.token, chat_id, chunk)droppedthread_identirely.Fix
_SLACK_THREAD_TARGET_RE = re.compile(r'^\s*([CGD][A-Z0-9]{8,})':([\d.]+)\s*$')— handlesCHANNEL_ID:THREAD_TSformat (Slack timestamps use decimal notation like1778181769.602679)._parse_target_refto try the thread regex first, then fall back to bare-channel regex (no breakage of existing behaviour).thread_id=Noneparam to_send_slack()and injectpayload["thread_ts"] = thread_idwhen set.thread_id=thread_idin_send_to_platform()dispatch.Tests
assert_awaited_once_withassertion to includethread_id=Nonekeyword arg.test_channel_with_thread_ts_is_parsed— verifiesC0B0GV4FKK7:1778181769.602679parses to(chat_id="C0B0GV4FKK7", thread_id="1778181769.602679", is_explicit=True).test_bare_channel_still_works_after_thread_regex— regression guard for bare channel ID path.All 97 tests pass (
pytest tests/tools/test_send_message_tool.py).