Skip to content

feishu: honor configured default account in outbound resolution#32253

Merged
steipete merged 2 commits intoopenclaw:mainfrom
bmendonca3:bm/feishu-default-account-outbound-r3
Mar 3, 2026
Merged

feishu: honor configured default account in outbound resolution#32253
steipete merged 2 commits intoopenclaw:mainfrom
bmendonca3:bm/feishu-default-account-outbound-r3

Conversation

@bmendonca3
Copy link

Summary

  • Problem: Feishu defaultAccount preference can be ignored when the preferred id is not present in accounts map.
  • Why it matters: outbound account resolution can route through an unintended account.
  • What changed: default account resolution now honors configured defaultAccount directly, with normalization and regression coverage.
  • What did NOT change: no changes to credential loading semantics beyond account selection precedence.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • 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

  • Closes #
  • Related #

User-visible / Behavior Changes

  • Feishu account selection now respects configured defaultAccount even when account entries are sparse.

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

Repro + Verification

Steps

  1. Configure channels.feishu.defaultAccount to a value not present in channels.feishu.accounts keys.
  2. Resolve default Feishu account id and run account resolution without explicit accountId.
  3. Verify preferred defaultAccount is used.

Evidence

  • Failing test/log before + passing after

Human Verification (required)

  • Verified scenarios: pnpm -s vitest run extensions/feishu/src/accounts.test.ts
  • Edge cases checked: normalization and missing-account-map preference behavior.
  • What you did not verify: live Feishu API call path.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert this PR commit.
  • Files/config to restore: extensions/feishu/src/accounts.ts, extensions/feishu/src/accounts.test.ts
  • Known bad symptoms reviewers should watch for: wrong Feishu account selected for outbound actions.

Risks and Mitigations

  • Risk: behavior shift for configurations that relied on previous fallback selection.
    • Mitigation: explicit regression tests document and lock expected precedence.

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: 6d46a70387

ℹ️ 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 +40 to 41
if (preferred) {
return preferred;

Choose a reason for hiding this comment

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

P2 Badge Restore fallback when preferred account has no config

Returning preferred unconditionally here causes stale or typoed channels.feishu.defaultAccount values to resolve to an account ID that may not exist in accounts. In common multi-account configs where credentials are only stored under accounts[...], resolveFeishuAccount then produces an unconfigured account and downstream calls (for example message sends) fail with missing-credentials errors, while the previous logic safely fell back to default/first configured account. This can be triggered after deleting the previously default account because defaultAccount is not cleared in extensions/feishu/src/channel.ts.

Useful? React with 👍 / 👎.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR fixes a bug in Feishu account resolution where the configured defaultAccount preference could be silently ignored if that account ID wasn't present in the accounts map. The fix removes the validation check ids.includes(preferred) so that the configured defaultAccount is always honored, even when not explicitly defined in the accounts map. This allows the account to fall back to base credentials, which is the correct behavior per the configuration hierarchy. The change is minimal (3 lines of code logic), focused on the specific issue, and includes regression test coverage that documents the expected precedence behavior.

Confidence Score: 4/5

  • Safe to merge with minimal risk
  • The change is focused, well-tested, and fixes a legitimate bug in account resolution logic. Downstream code (resolveFeishuAccount) handles the case where an account ID might not be in the accounts map by gracefully falling back to base credentials. One point deducted for potential backward compatibility impact on configurations that may have relied on the previous fallback behavior, though the old behavior was arguably incorrect as it ignored explicit user configuration.
  • No files require special attention

Last reviewed commit: 6d46a70

@steipete steipete force-pushed the bm/feishu-default-account-outbound-r3 branch from 6d46a70 to 050d903 Compare March 3, 2026 01:13
@steipete steipete merged commit 1187464 into openclaw:main Mar 3, 2026
9 checks passed
@aisle-research-bot
Copy link

aisle-research-bot bot commented Mar 3, 2026

🤖 We're reviewing this PR with Aisle

We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛
We'll post the results here as soon as they're ready.

Progress:

  • Analysis
  • Triage
  • Finalization

Latest run failed. Keeping previous successful results. Trace ID: 019cb141a43d931d0b85df2e1c7762c9.

Last updated on: 2026-03-03T01:13:27Z

@steipete
Copy link
Contributor

steipete commented Mar 3, 2026

Landed via temp rebase onto main.

  • Gate:
    RUN v4.0.18 /Users/steipete/Projects/clawdbot2

✓ extensions/feishu/src/accounts.test.ts (7 tests) 10ms

Test Files 1 passed (1)
Tests 7 passed (7)
Start at 01:13:26
Duration 294ms (transform 143ms, setup 156ms, import 22ms, tests 10ms, environment 0ms)

Thanks @bmendonca3!

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: 050d903cf8

ℹ️ 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 +40 to 41
if (preferred) {
return preferred;

Choose a reason for hiding this comment

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

P2 Badge Keep fallback when default account key is missing

Returning preferred unconditionally means a stale or misspelled channels.feishu.defaultAccount now resolves to an account ID that may not exist in accounts, so resolveFeishuAccount({ accountId: undefined }) can become unconfigured when credentials are only stored under accounts[...] and outbound sends fail with missing credentials instead of falling back to a valid account. Fresh evidence: extensions/feishu/src/channel.ts only validates defaultAccount as a plain string (no membership check), and deleteAccount does not clear defaultAccount, so this bad state is reachable through normal config edits.

Useful? React with 👍 / 👎.

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.

2 participants