[slack] [bug] resolve structured streaming team context from interactive payloads#330
Open
mdnanocom wants to merge 1 commit intovercel:mainfrom
Open
Conversation
Contributor
|
@mdnanocom is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fix Slack structured streaming when
thread.post(stream)is called from an action-created thread.Slack structured streaming needs a valid
recipientTeamId. This change makes team context derivation more tolerant when building streaming options fromcurrentMessage.rawby supporting:team_idteamas a stringteam.idThat covers both standard Slack message events and interactive
block_actionspayloads.Why this fixes the bug
The failure only showed up for action-created threads.
For message-created threads,
currentMessage.rawis typically a Slack message event, so the previous logic usually worked:For action-created threads,
currentMessage.rawis the fullblock_actionspayload. In that payload shape,teamis commonly an object instead of a string. That meant the previous logic could derive an object where Slack expects a workspace ID string, which breaks structured streaming.Payload shape difference
Working path: message event
Slack message event payload example:
{ "type": "event_callback", "team_id": "TEAM_ID", "event": { "type": "message", "user": "USER_ID", "text": "...", "team": "TEAM_ID", "thread_ts": "1234567890.123456", "channel": "CHANNEL_ID" }, "authorizations": [ { "team_id": "TEAM_ID" } ] }The raw message shape that matters to stream context effectively looks like:
{ "type": "message", "user": "USER_ID", "team": "TEAM_ID", "thread_ts": "1234567890.123456", "channel": "CHANNEL_ID" }In this case, the previous derivation still returned a string team ID.
Failing path:
block_actionsOn the failing path,
currentMessage.rawis the fullblock_actionspayload, andteamis an object:{ "type": "block_actions", "user": { "id": "USER_ID", "team_id": "TEAM_ID" }, "container": { "message_ts": "1234567890.123456", "channel_id": "CHANNEL_ID", "thread_ts": "1234567890.123456" }, "team": { "id": "TEAM_ID", "domain": "workspace-domain" }, "channel": { "id": "CHANNEL_ID" }, "message": { "type": "message", "team": "TEAM_ID", "thread_ts": "1234567890.123456" }, "actions": [ { "action_id": "action-id", "value": "action-value" } ] }The important mismatch is:
{ "user": { "team_id": "TEAM_ID" }, "team": { "id": "TEAM_ID", "domain": "..." }, "message": { "team": "TEAM_ID" } }With the previous logic:
recipientTeamIdcould become:instead of "TEAM_ID"