fix(slack): override wrong channel_type for D-prefix DM channels#25479
Merged
steipete merged 3 commits intoopenclaw:mainfrom Feb 24, 2026
Merged
fix(slack): override wrong channel_type for D-prefix DM channels#25479steipete merged 3 commits intoopenclaw:mainfrom
steipete merged 3 commits intoopenclaw:mainfrom
Conversation
07d77c4 to
aacddc6
Compare
Contributor
obviyus
pushed a commit
to Glucksberg/OpenClaw
that referenced
this pull request
Feb 24, 2026
margulans
pushed a commit
to margulans/Neiron-AI-assistant
that referenced
this pull request
Feb 25, 2026
Jackson3195
pushed a commit
to Jackson3195/openclaw-with-a-personal-touch
that referenced
this pull request
Feb 25, 2026
brianleach
pushed a commit
to brianleach/openclaw
that referenced
this pull request
Feb 26, 2026
2 tasks
execute008
pushed a commit
to execute008/openclaw
that referenced
this pull request
Feb 27, 2026
r4jiv007
pushed a commit
to r4jiv007/openclaw
that referenced
this pull request
Feb 28, 2026
6 tasks
Maple778
added a commit
to Maple778/openclaw
that referenced
this pull request
Mar 2, 2026
…correct external data Pattern from PR openclaw#25479 The bug is located in the `resolveModalSessionRouting` function, which orchestrates modal session routing by relying on `metadata.channelType`. The root cause is that this metadata originates from an untrusted external source (Slack modal submission payload) and may contradict the structural reality of the `channelId` (e.g., a 'C' prefix ID marked as 'im'). If passed downstream to `ctx.resolveSlackSystemEventSessionKey` or stored as the source of truth for the channel type, this causes data corruption. The fix implements the 'ground truth' strategy mentioned in PR openclaw#25479: deterministically inferring the type from the `channelId` prefix (D/G/C) and overriding the metadata if a contradiction is detected for DMs. This ensures the system relies on data structure rather than user input.
joelnishanth
pushed a commit
to joelnishanth/openclaw
that referenced
this pull request
Mar 3, 2026
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
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
channel_typemetadatadmScope: "main"routing, fragments DM conversations across separate sessions, bypasses DM policiesnormalizeSlackChannelType()to override wrongchannel_typewhen channel ID is D-prefixChange Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Before:
channel_type: "channel"→ classified as channelsagent:main:slack:channel:d0abc123(bypasses dmScope)After:
"im"regardless ofchannel_typeagent:main:mainwhendmScope: "main"Security Impact (required)
No)No)No)No)No)Repro + Verification
Environment
Steps
session.dmScope: "main"andchannels.slack.dm.policy: "open"openclaw sessions listagent:main:slack:channel:d0abc123agent:main:mainExpected
"im"typedmScope: "main"Actual
"im"(cross-validation)Evidence
Test coverage:
Unit tests (
monitor.test.ts- 3 new):channel_type("channel","group","mpim") for D-prefix → returns"im"channel_type("im") for D-prefixIntegration tests (
prepare.test.ts- 2 new):channel_type: "channel"→isDirectMessage: true, routes toagent:main:main,ChatType: "direct"channel_type→ correctly inferred as DMAll 5 new tests pass. All existing tests pass.
Human Verification (required)
What you personally verified (not just CI), and how:
Verified scenarios:
pnpm buildsucceedspnpm checkpasses (oxlint + typecheck)Edge cases checked:
channel_type: "im"(preserved)channel_type: "channel"(overridden to"im")channel_type: "group"(overridden to"im")channel_type: "mpim"(overridden to"im")channel_type(inferred as"im")What I did NOT verify:
Compatibility / Migration
Yes)No)No)This is a pure bug fix to normalization logic. No config changes or migrations required.
Failure Recovery (if this breaks)
src/slack/monitor/context.tsRisks and Mitigations
Risk: Over-aggressive override might affect non-DM D-prefix channels (if Slack ever creates them)
Risk: Changes might affect G-prefix channels
Risk: Existing sessions with wrong classification might not auto-migrate
Greptile Summary
Adds cross-validation logic to override incorrect
channel_typemetadata for Slack DM channels (D-prefix IDs). When Slack sends contradicting metadata (e.g., D-prefix channel withchannel_type: "channel"), the fix correctly overrides to"im"based on the definitive D-prefix identifier.Key changes:
normalizeSlackChannelType()insrc/slack/monitor/context.ts:48-51to check if inferred type is"im"and override when normalized type doesn't match"channel","group","mpim"), preserved correct type, and G-prefix ambiguity handlingchannel_typeroutes correctly to main session, and missingchannel_typeis correctly inferredThe fix is surgical and limited to D-prefix channels only. G-prefix and C-prefix channels remain unaffected. Test coverage comprehensively validates the fix matches the described behavior.
Confidence Score: 5/5
Last reviewed commit: 07d77c4