fix(slack): guard _resolve_thread_ts against async/cron deliveries using stale thread context

Cron/async deliveries (reply_to=None) should always go to the home/target
channel, but _resolve_thread_ts() returns metadata.thread_id/thread_ts even
when reply_to is None, routing messages to the thread where the cron job
was created instead of the configured home channel.

Add early return None when reply_to is None, so async deliveries never
inherit stale thread context from metadata.

Closes #59097
This commit is contained in:
Wesley Simplicio 2026-07-05 18:39:25 -03:00 committed by Teknium
parent 1c30b9bf59
commit 223aa88a99
No known key found for this signature in database

View file

@ -2188,6 +2188,13 @@ class SlackAdapter(BasePlatformAdapter):
thread replies. Messages that originate inside an existing thread are
always replied to in-thread to preserve conversation context.
"""
# Guard: async/cron deliveries (reply_to=None) should always go to
# the home/target channel, never to a stale thread context captured
# in metadata. Only real replies to inbound messages preserve thread
# routing.
if reply_to is None:
return None
# When reply_in_thread is disabled (default: True for backward compat),
# only thread messages that are already part of an existing thread.
# For top-level channel messages, the inbound handler sets