Skip to content

Feishu: normalize group announce targets to chat ids#31546

Merged
Takhoffman merged 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:fix/feishu-group-target-normalize-31426
Mar 2, 2026
Merged

Feishu: normalize group announce targets to chat ids#31546
Takhoffman merged 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:fix/feishu-group-target-normalize-31426

Conversation

@liuxiaopai-ai
Copy link

Summary

  • normalize Feishu targets with group: and channel: prefixes to chat IDs
  • keep existing chat:/user:/open_id: behavior unchanged
  • add regression tests so normalized group:oc_* and channel:oc_* resolve as chat_id

Problem

sessions_send announce can route Feishu group targets as group:oc_*.
Feishu target normalization previously left that prefix intact, so send path defaulted to user_id, causing API 400 errors for group announce delivery.

Validation

  • pnpm test extensions/feishu/src/targets.test.ts
  • pnpm exec oxlint extensions/feishu/src/targets.ts extensions/feishu/src/targets.test.ts

Fixes #31426

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47c9c0e8b6

ℹ️ 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".

Comment on lines +36 to +40
if (lowered.startsWith("group:")) {
return withoutProvider.slice("group:".length).trim() || null;
}
if (lowered.startsWith("channel:")) {
return withoutProvider.slice("channel:".length).trim() || null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep prefixed * from becoming wildcard entries

Stripping group:/channel: unconditionally here turns inputs like group:* and channel:* into bare *, which resolveFeishuAllowlistMatch treats as a global wildcard (extensions/feishu/src/policy.ts:36). That means a misconfigured groupAllowFrom/sender allowlist entry can now silently flip from deny-all (previous behavior) to allow-all for every group or sender, which is a security-sensitive regression in allowlist enforcement.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR fixes a bug where Feishu group announcements routed as group:oc_* or channel:oc_* were incorrectly sent via user_id API parameters, causing 400 errors. The fix normalizes these prefixes to chat IDs by extending the target normalization logic.

Key changes:

  • Added group: and channel: prefix handling in normalizeFeishuTarget() to strip these prefixes (matching existing chat: behavior)
  • Updated looksLikeFeishuId() regex to recognize group and channel as valid prefix patterns
  • Added comprehensive test coverage for the new normalization paths and their integration with resolveReceiveIdType()

Impact: The implementation correctly routes group:oc_*oc_*chat_id, fixing the API parameter mismatch. No breaking changes—existing chat:, user:, and open_id: prefixes continue working as before.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean, focused bug fix with comprehensive test coverage, follows existing code patterns exactly, no breaking changes, and the implementation correctly addresses the root cause described in the PR
  • No files require special attention

Last reviewed commit: 47c9c0e

@Takhoffman Takhoffman force-pushed the fix/feishu-group-target-normalize-31426 branch from 47c9c0e to 04ca26f Compare March 2, 2026 22:50
@Takhoffman Takhoffman merged commit fa47f74 into openclaw:main Mar 2, 2026
9 of 10 checks passed
@Takhoffman
Copy link
Contributor

PR #31546 - Feishu: normalize group announce targets to chat ids (#31546)

Merged after verification.

  • Merge commit: fa47f74
  • Verified: pnpm build, pnpm check (baseline unrelated lint issues on main), pnpm test:macmini
  • Autoland updates:
    M\tCHANGELOG.md
    M\textensions/feishu/src/targets.test.ts
    M\textensions/feishu/src/targets.ts
  • Rationale:
    Canonicalize Feishu target normalization by adding channel: alias support while preserving existing group:/dm: behavior and receive-id semantics on current main.
  • Changelog: CHANGELOG.md updated=true required=true opt_out=false

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 04ca26fc4e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +39 to +40
if (lowered.startsWith("channel:")) {
return withoutProvider.slice("channel:".length).trim() || null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat channel: targets as chat IDs in receive type resolution

Adding channel: normalization here makes normalizeFeishuTarget("channel:oc_...") return a chat ID, but resolveReceiveIdType still does not recognize the channel: prefix and falls back to user_id. In the send path (extensions/feishu/src/send-target.ts), that combination sends receive_id=oc_... with receive_id_type=user_id, which causes Feishu API failures for channel-targeted sends instead of routing as chat_id.

Useful? React with 👍 / 👎.

dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
… thanks @liuxiaopai-ai

Verified:
- pnpm build
- pnpm check (fails on unrelated existing main-branch lint violations in ui/src/ui/views/agents-utils.ts and src/pairing/pairing-store.ts)
- pnpm test:macmini

Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
OWALabuy pushed a commit to kcinzgg/openclaw that referenced this pull request Mar 4, 2026
… thanks @liuxiaopai-ai

Verified:
- pnpm build
- pnpm check (fails on unrelated existing main-branch lint violations in ui/src/ui/views/agents-utils.ts and src/pairing/pairing-store.ts)
- pnpm test:macmini

Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
… thanks @liuxiaopai-ai

Verified:
- pnpm build
- pnpm check (fails on unrelated existing main-branch lint violations in ui/src/ui/views/agents-utils.ts and src/pairing/pairing-store.ts)
- pnpm test:macmini

Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sessions_send announce fails in Feishu group: passes group ID as user_id

2 participants