Skip to content

fix(feishu): preserve top-level groupPolicy and avoid duplicate registration - #65398

Closed
bin448482 wants to merge 2 commits into
openclaw:mainfrom
bin448482:fix-feishu-duplicate-registration
Closed

bin448482 wants to merge 2 commits into
openclaw:mainfrom
bin448482:fix-feishu-duplicate-registration

Conversation

@bin448482

Copy link
Copy Markdown

Summary

  • Problem: Feishu had two regressions in the same flow: repeated tool/hook registration on plugin cache misses, and named-account config loads silently rewrote top-level groupPolicy: "open" back to allowlist.
  • Why it matters: repeated registrations add log noise and risk duplicate side effects, while the groupPolicy rewrite blocks group replies even when the user explicitly configured Feishu groups to stay open.
  • What changed: added an idempotency guard around Feishu registerFull, declared Feishu-specific named-account promotion keys, added the early promotion fallback used by legacy config loading, and locked the behavior with regression tests.
  • What did NOT change (scope boundary): this does not change generic promotion behavior for other channels, and it does not alter Feishu routing or security defaults outside the named-account migration path.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: Feishu registerFull had no idempotency guard when plugin loader cache misses caused re-registration, and Feishu had no named-account promotion contract, so legacy config normalization treated shared top-level policy keys like single-account fields and moved groupPolicy into accounts.default.
  • Missing detection / guardrail: there was no regression coverage for repeated Feishu full registration or for loading a named-account Feishu config with top-level groupPolicy: "open".
  • Contributing context (if known): the live config on the affected machine used channels.feishu.defaultAccount = "main" with named main/candy accounts and a top-level groupPolicy, which hits the legacy promotion path.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/feishu/index.test.ts, extensions/feishu/src/setup-surface.test.ts, src/commands/doctor-legacy-config.migrations.test.ts
  • Scenario the test should lock in: rerunning Feishu full registration must not duplicate tools/hooks, and loading Feishu named-account configs must preserve top-level groupPolicy and avoid synthesizing accounts.default.
  • Why this is the smallest reliable guardrail: the bug lives in the entry registration seam and the legacy config normalization seam; both are reproducible without booting the full gateway.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

  • Feishu group messages respect a top-level channels.feishu.groupPolicy again when named accounts are configured.
  • Feishu tools and subagent hooks no longer re-register repeatedly when plugin cache misses cause registerFull to rerun.

Diagram (if applicable)

N/A.

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: Ubuntu Linux
  • Runtime/container: Node v24.14.0, local gateway service
  • Model/provider: minimax/MiniMax-M2.7
  • Integration/channel (if any): Feishu (websocket mode)
  • Relevant config (redacted): channels.feishu.defaultAccount = "main", named main/candy accounts, top-level groupPolicy = "open", wildcard group route with requireMention = false

Steps

  1. Configure Feishu with named accounts and a top-level groupPolicy: "open".
  2. Start the gateway and load config through the normal runtime path.
  3. Send a Feishu group message and watch the runtime config and gateway logs.

Expected

  • Top-level channels.feishu.groupPolicy stays open.
  • No synthetic channels.feishu.accounts.default is created.
  • Feishu group messages are accepted under the configured open policy.
  • Feishu tools/hooks register once per process.

Actual

  • Before the fix, runtime config rewrote the top-level groupPolicy to allowlist, created accounts.default.groupPolicy = "open", and dropped group messages with groupPolicy=allowlist logs.
  • Before the fix, repeated Feishu tool registration logs appeared when full registration reran.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: reproduced the bad loaded runtime config on the affected machine, patched the code, confirmed both src and dist loadConfig() preserved top-level groupPolicy: "open", restarted the live gateway service, and confirmed Feishu messages started arriving again.
  • Edge cases checked: named-account Feishu config without an existing default account, shared top-level auth plus shared top-level policy, repeated registerFull calls.
  • What you did not verify: webhook mode and account-specific groupPolicy overrides were not retested in a live environment.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: Feishu named-account promotion now keeps shared top-level auth/policy fields in place instead of synthesizing accounts.default.
    • Mitigation: the change is limited to Feishu, the early fallback matches the Feishu setup contract, and regression tests cover both the migration seam and the entry registration seam.

@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two Feishu regressions: (1) repeated tool/hook registration on plugin cache misses, addressed with a module-level idempotency flag in registerFull; and (2) top-level groupPolicy: "open" being silently rewritten to allowlist when named accounts were configured, fixed by adding Feishu-specific namedAccountPromotionKeys to both the setup adapter and the early-migration fallback table in core.

The implementation is sound and regression tests cover both scenarios. One architectural note: BUNDLED_NAMED_ACCOUNT_PROMOTION_FALLBACKS in setup-promotion-helpers.ts now contains hardcoded Feishu and Telegram entries in core — this extends an existing (pre-PR) pattern rather than introducing a new one, but CLAUDE.md's architecture rule calls for plugin-owned contracts over named special cases in core; the fallback is justified by early-migration paths running before channel setup surfaces are loaded, which the inline comment explains.

Confidence Score: 5/5

Safe to merge — both regressions are correctly fixed with targeted, backward-compatible changes and regression tests.

No P0 or P1 issues found. The idempotency guard and named-account promotion filter are logically correct, consistent with the Telegram precedent, and covered by focused tests. The only note is an architectural P2 about hardcoded channel names in the early-migration fallback table, which is an existing pattern rather than a new one.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(feishu): preserve top-level groupPol..." | Re-trigger Greptile

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

Copy link
Copy Markdown
Contributor

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: 782e3f3eb5

ℹ️ 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 +84 to +87
if (feishuToolsRegistered) {
return;
}
feishuToolsRegistered = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Scope Feishu full-registration guard to each registry load

This module-level feishuToolsRegistered flag makes registerFull a one-shot for the lifetime of the process, so any later full registration (for example an activating plugin reload) will skip all Feishu hook/tool registration. loadOpenClawPlugins explicitly clears previously registered plugin state on activating reloads (src/plugins/loader.ts:1132-1138), so after the first reload Feishu can end up with no subagent hooks/tools in the new registry even though the plugin is still loaded.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

The PR addresses a real Feishu regression, but it is not merge-ready because the duplicate-registration fix uses a process-global guard that can skip Feishu hook/tool registration for a rebuilt plugin registry, and the external PR still lacks inspectable redacted real Feishu proof.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection gives a high-confidence path for both sides: current config normalization can move top-level Feishu policy without a named-account filter, and the PR's process-global guard can skip registration after a registry rebuild; I did not run a live Feishu session in this read-only review.

Is this the best way to solve the issue?

No, not as written. The named-account promotion fix is a plausible narrow direction, but the duplicate-registration fix belongs at a registry/API or loader lifecycle boundary rather than a process-lifetime module flag.

Security review:

Security review cleared: No concrete security or supply-chain regression was found; the diff changes Feishu registration/config normalization and tests without new dependencies, workflows, permissions, secret handling, or network calls.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-12T14:30:05Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: History shows substantial recent work on bundled channel bootstrap boundaries and Feishu doc/tool routing, both adjacent to the registration and plugin-boundary behavior reviewed here. (role: recent area contributor; confidence: high; commits: 3126809cb06a, 39b5ffdaa600; files: extensions/feishu/index.ts, extensions/feishu/src/docx.ts, src/channels/plugins/setup-promotion-helpers.ts)
  • vincentkoc: Current-main blame and history show recent work creating the current Feishu entrypoint, plugin loader, and setup-promotion helper files during release/runtime build refactors. (role: recent area contributor; confidence: high; commits: 94833b2c9072, 78fb35250690, 8c802aa68351; files: extensions/feishu/index.ts, src/plugins/loader.ts, src/channels/plugins/setup-promotion-helpers.ts)
  • Takhoffman: History shows Feishu ACP and subagent session-binding work, which is adjacent to the Feishu subagent hook registration path affected by this PR. (role: adjacent Feishu feature owner; confidence: medium; commits: 89e3969d640c; files: extensions/feishu/index.ts, extensions/feishu/src/subagent-hooks.ts)

Codex review notes: model internal, reasoning high; reviewed against 865e4db1cd0a.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 19, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 4, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 5, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 5, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant