fix(slack): classify D-prefix DMs correctly when channel_type disagrees#10643
Closed
mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
Closed
fix(slack): classify D-prefix DMs correctly when channel_type disagrees#10643mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
mcaxtr wants to merge 2 commits intoopenclaw:mainfrom
Conversation
src/slack/monitor/message-handler/prepare.inbound-contract.test.ts
Outdated
Show resolved
Hide resolved
Contributor
Author
|
@greptileai review |
63a9cef to
3aaedf8
Compare
3aaedf8 to
6f166b6
Compare
6f166b6 to
4e30a18
Compare
4ab4a4f to
49bcf8f
Compare
bfc1ccb to
f92900f
Compare
dfab4a8 to
78f4f13
Compare
78f4f13 to
9fb21fd
Compare
Contributor
|
Closing as AI-assisted stale-fix triage. Linked issue #8421 ("Slack DMs Misclassified as Channels - dmScope 'main' Not Working") is currently CLOSED and was closed on 2026-02-24T04:24:48Z with state reason NOT_PLANNED. If the underlying bug is still reproducible on current main, please reopen this PR (or open a new focused fix PR) and reference both #8421 and #10643 for fast re-triage. |
Contributor
|
Closed after AI-assisted stale-fix triage (closed issue duplicate/stale fix). |
18 tasks
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.
Fixes #8421
Problem
Slack sometimes sends events where the
channel_typefield contradicts the channel ID prefix. For example, a DM channel with IDD0ABC123may arrive withchannel_type: "channel"instead of"im". This causes the bot to misclassify DMs as public channels, leading to:agent:main:slack:channel:D0ABC123instead ofagent:main:main(whendmScopeis"main")ChatType: set to"channel"instead of"direct"Root Cause
normalizeSlackChannelType()incontext.tstrusts the event'schannel_typefield when it's a recognized value ("im","mpim","channel","group"), even when the channel ID prefix contradicts it. Since Slack channel IDs withDprefix are always DMs by Slack's own convention, thechannel_typefield should be overridden when it disagrees.Fix
Added a cross-validation check in
normalizeSlackChannelType(): when the channel ID starts withD(inferred as"im"), override any contradictingchannel_typevalue. This is the canonical normalization function used across the entire Slack integration — all downstream callers (prepareSlackMessage,isChannelAllowed,resolveSlackSystemEventSessionKey, member events) are automatically protected.Only
D-prefix is overridden because it unambiguously identifies DMs.G-prefix is intentionally left alone since it's ambiguous (can be either a private channel or a group DM — Slack's API provides the correctchannel_typein that case).Test Plan
TDD approach — all 8 new tests were written first and confirmed failing before the fix:
normalizeSlackChannelTypeunit tests (3 cases):channel_type("channel","group","mpim") for D-prefix channels → returns"im"channel_type("im") for D-prefix channelsprepareSlackMessageintegration tests (2 cases):channel_type: "channel"→isDirectMessage: true, session routes toagent:main:main,ChatType: "direct"channel_type→ correctly inferred as DMpnpm build && pnpm check && pnpm testGreptile Overview
Greptile Summary
normalizeSlackChannelType()to cross-check the channel ID prefix and override contradictorychannel_typevalues forD*channels (treat asim).G*channels unchanged.prepareSlackMessagecontract tests to ensure D-prefix DMs route to the main DM session and produceChatType: directeven when Slack mislabelschannel_type.Confidence Score: 5/5