fix(feishu): admit groups explicitly listed under channels.feishu.groups (#67687)#72789
Conversation
Greptile SummaryThis PR fixes a bug where Feishu group messages were silently dropped when a group was explicitly configured under Confidence Score: 5/5This PR is safe to merge — the fix is minimal, well-targeted, and backed by a regression test. The change is a single short-circuit in the group admission gate, all other security guards remain intact, and a regression test covering the exact reported config shape passes. No cross-plugin risk since the fix is plugin-local. No files require special attention. Reviews (1): Last reviewed commit: "fix(feishu): admit groups explicitly lis..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b5c963bed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const groupExplicitlyConfigured = groupConfig !== undefined; | ||
|
|
||
| // Check if this GROUP is allowed (groupAllowFrom contains group IDs like oc_xxx, not user IDs) | ||
| const groupAllowed = isFeishuGroupAllowed({ | ||
| groupPolicy, | ||
| allowFrom: groupAllowFrom, | ||
| senderId: ctx.chatId, // Check group ID, not sender ID | ||
| senderName: undefined, | ||
| }); | ||
| const groupAllowed = | ||
| groupExplicitlyConfigured || |
There was a problem hiding this comment.
Preserve groupPolicy checks when applying group overrides
groupAllowed now short-circuits to true whenever groupConfig is defined, which skips isFeishuGroupAllowed entirely. Because resolveFeishuGroupConfig can return wildcard config (groups["*"]) for any chat ID (extensions/feishu/src/policy.ts:128-149), a wildcard per-group override like requireMention will admit every group regardless of groupAllowFrom, and even bypass groupPolicy: "disabled". This is an access-control regression for allowlist/disabled deployments and was introduced by this change.
Useful? React with 👍 / 👎.
710c0be to
c31255f
Compare
…ups (openclaw#67687) Feishu config defaults groupPolicy to 'allowlist'. Inbound group handling read groupAllowFrom and called isFeishuGroupAllowed before resolveFeishuReplyPolicy was reached, so a config that only set channels.feishu.groups.<chat_id>.requireMention=false (with no groupAllowFrom) was rejected with 'group not in groupAllowFrom' before per-group requireMention could take effect. Treat the explicit presence of a group entry under channels.feishu.groups as the operator's allowlist signal: if groupConfig is defined, skip the empty-allowlist rejection. resolveFeishuReplyPolicy still owns mention gating, and existing groupConfig.enabled=false / groupAllowFrom-driven rejections are preserved. Adds a regression test that exercises the reporter's exact config shape and confirms inbound text reaches finalize/dispatch.
c31255f to
a8e2b11
Compare
Summary
A Feishu group whose only configured override is
channels.feishu.groups.<chat_id>.requireMention=false(with nogroupAllowFrom) was silently dropped on the inbound path because the schema-defaultgroupPolicy="allowlist"rejects an empty allowlist before the per-grouprequireMentionis ever evaluated. Treat the explicit presence of a group entry underchannels.feishu.groupsas the operator's allowlist signal so the per-group settings actually take effect.Root Cause
In
extensions/feishu/src/bot.ts,handleFeishuMessageresolvesgroupConfigfromchannels.feishu.groups.<chat_id>and then runsisFeishuGroupAllowed({ groupPolicy, allowFrom: groupAllowFrom, ... })against the top-levelgroupAllowFromonly. With the validated config defaults (groupPolicy="allowlist",groupAllowFrom=[]),evaluateSenderGroupAccessForPolicyreturnsallowed:false, reason:"empty_allowlist"andhandleFeishuMessagereturns beforeresolveFeishuReplyPolicy(which honors per-grouprequireMention) ever runs. Result: every group message is dropped, exactly as reported by @Artyomkun in #67687.Changes
extensions/feishu/src/bot.ts: in the group admission block, check whether the group is explicitly listed underchannels.feishu.groups.<chat_id>(via the already-resolvedgroupConfig). If yes, treat it as admitted regardless ofgroupAllowFrom. Existing behaviors are preserved:groupConfig.enabled === falsestill drops the message, the per-sendereffectiveGroupSenderAllowFromallowlist still applies, andresolveFeishuReplyPolicystill owns mention gating.extensions/feishu/src/bot.test.ts: add a regression test that exercises the reporter's exact config shape (onlygroups."oc-explicit-group".requireMention=false, no top-levelgroupAllowFrom, defaultgroupPolicy="allowlist") and asserts the inbound text reachesfinalizeInboundContext/dispatchReplyFromConfig.Reproduction (before fix)
With the reporter's config and the prior code,
handleFeishuMessagelogsfeishu[<account>]: group <chat_id> not in groupAllowFrom (groupPolicy=allowlist)and returns. The new test inbot.test.tsfailed before this fix (it expectedmockFinalizeInboundContext/mockDispatchReplyFromConfigto be called and they were not, because the function returned at the admission gate).Verification (after fix)
pnpm tsgo:prod(core + extensions) andpnpm lint:extensionsboth exit0. Full extension suite shows 663/666 pass; the 3 failures are inextensions/feishu/src/docx.test.ts(feishu_doc image fetch hardening), reproduce onupstream/mainwithout this change, and are unrelated to the group admission code path.Test
extensions/feishu/src/bot.test.ts > admits group when chat_id is explicitly configured under groups, even with empty groupAllowFrom (#67687)— verifies the reporter's config shape is admitted.pnpm test extensions/feishu/src/bot.test.ts— 55/55 pass.src/plugin-sdk/group-access.ts(shared by Teams/Mattermost/Zalo/Feishu); fix is intentionally plugin-local to avoid cross-plugin regressions.Notes
clawsweeper's review on [Bug]: Group messages not reaching session - requireMention: false not working (Feishu) #67687 ("treat explicitchannels.feishu.groups.<chat_id>entries as admitted groups undergroupPolicy: 'allowlist'").groupAllowFrompopulated, orgroupPolicy="open", or nogroups.<chat_id>entry) keep their existing behavior.Closes #67687