fix(discord): use guild_id as source of truth for DM classification#34416
Closed
Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(discord): use guild_id as source of truth for DM classification#34416Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Sid-Qin wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When channelInfo returned ChannelType.DM for a guild channel (stale cache or API inconsistency), the message was classified as a DM, bypassing the requireMention gate. guild_id is now authoritative: if present, the message is never treated as DM or GroupDM. Closes openclaw#34353 Made-with: Cursor
Contributor
Greptile SummaryThis PR fixes a regression where
Confidence Score: 5/5
Last reviewed commit: d7c4607 |
4 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.
Summary
requireMention: truestopped working — the agent responds and shows typing on every guild message even when not mentioned. The root cause is thatisDirectMessagewas derived solely fromchannelInfo?.type === ChannelType.DM, ignoringparams.data.guild_id. WhenchannelInforeturnedChannelType.DMfor a guild channel (stale cache, API inconsistency, or Carbon library change), guild messages were classified as DMs, bypassing therequireMentiongate entirely.requireMention: trueis broken — the bot responds to every message, flooding channels.message-handler.preflight.ts,isDirectMessageandisGroupDmnow require!isGuildMessageas a precondition. Ifguild_idis present, the message is never classified as DM or GroupDM — mirroring the existing pattern inagent-components.ts(line 214-217).resolveDiscordChannelInfo,resolveMentionGatingWithBypass, guild config resolution, and all other preflight checks are untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Guild messages without an explicit bot mention are correctly dropped when
requireMention: trueis configured, restoring pre-regression behavior.Security Impact (required)
Repro + Verification
Environment
Steps
requireMention: trueinguilds.<guildId>.Expected
Actual
Evidence
New test: "drops guild messages without mention even when channelInfo reports DM type (stale cache)" — simulates a guild message where
channelInfo.typeincorrectly returnsChannelType.DM, verifies the message is still dropped whenrequireMention: true.Human Verification (required)
guild_id+ stalechannelInfo.type=DMdropped. Guild message with correctchannelInfo.type=GuildTextstill works. True DMs (noguild_id,channelInfo.type=DM) still accepted.guild_idpresent butchannelInfonull results inisDirectMessage= false (correct). GroupDM withguild_idabsent still works viachannelInfo.type.Compatibility / Migration
Failure Recovery (if this breaks)
isDirectMessagereturns tochannelInfo?.type === ChannelType.DM.src/discord/monitor/message-handler.preflight.tsRisks and Mitigations
guild_idis absent from the event payload would fail to be recognized as guild.guild_idis a core Discord gateway field always present for guild messages. The same pattern is already proven inagent-components.tsfor interactions.