Skip to content

fix(feishu): tolerate missing webhook defaults in older plugin-sdk#31639

Merged
Takhoffman merged 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:codex/fix-feishu-webhook-default-fallback-31606
Mar 2, 2026
Merged

fix(feishu): tolerate missing webhook defaults in older plugin-sdk#31639
Takhoffman merged 1 commit intoopenclaw:mainfrom
liuxiaopai-ai:codex/fix-feishu-webhook-default-fallback-31606

Conversation

@liuxiaopai-ai
Copy link

Summary

  • Problem: Feishu plugin monitor state read WEBHOOK_RATE_LIMIT_DEFAULTS.windowMs and WEBHOOK_ANOMALY_COUNTER_DEFAULTS.* at module load, which can be undefined in mixed-version installs.
  • Why it matters: Feishu plugin can fail to load during onboarding/runtime with TypeError: Cannot read properties of undefined (reading 'windowMs').
  • What changed: added safe default resolvers for webhook rate-limit/anomaly defaults and used them when initializing Feishu monitor state.
  • What did NOT change (scope boundary): no behavior change for current SDK exports; only fallback behavior for missing/invalid defaults.

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

User-visible / Behavior Changes

  • Feishu plugin now starts cleanly in mixed-version setups where openclaw/plugin-sdk does not expose webhook default constants.

Security Impact (required)

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

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node + pnpm
  • Model/provider: N/A
  • Integration/channel (if any): Feishu plugin
  • Relevant config (redacted): Feishu webhook mode

Steps

  1. Load Feishu monitor state with missing webhook-default constants from plugin-sdk.
  2. Initialize rate limiter / anomaly tracker.
  3. Verify plugin initialization succeeds with safe fallback defaults.

Expected

  • No module-load crash when defaults are missing; fallback values are applied.

Actual

  • Added deterministic fallback resolution and regression tests for missing/invalid defaults.

Evidence

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

Human Verification (required)

  • Verified scenarios:
    • pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
    • pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
  • Edge cases checked:
    • missing defaults
    • partially invalid defaults (zero/negative/NaN)
  • What you did not verify:
    • full live Feishu end-to-end webhook flow in this run.

Compatibility / Migration

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

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
    • Revert commit 985cb5446.
  • Files/config to restore:
    • extensions/feishu/src/monitor.state.ts
    • extensions/feishu/src/monitor.state.defaults.test.ts
  • Known bad symptoms reviewers should watch for:
    • unexpected fallback behavior when SDK defaults are present and valid.

Risks and Mitigations

  • Risk: fallback normalization may hide malformed values.
    • Mitigation: fallback only applies to missing/invalid numeric fields and keeps valid provided values unchanged.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR fixes a module-load crash in the Feishu plugin that occurs in mixed-version environments where older openclaw/plugin-sdk builds don't export webhook default constants.

Key changes:

  • Added local fallback constants (FEISHU_WEBHOOK_RATE_LIMIT_FALLBACK_DEFAULTS and FEISHU_WEBHOOK_ANOMALY_FALLBACK_DEFAULTS) matching SDK defaults
  • Implemented coercePositiveInt helper to validate and normalize numeric config values (rejects non-finite, zero, and negative values)
  • Created resolver functions (resolveFeishuWebhookRateLimitDefaultsForTest and resolveFeishuWebhookAnomalyDefaultsForTest) that safely merge SDK exports with fallbacks
  • Added comprehensive test coverage for missing and partially-invalid defaults
  • Updated CHANGELOG with clear description of the fix

Impact:

  • Prevents TypeError: Cannot read properties of undefined (reading 'windowMs') during plugin initialization
  • No behavior change when SDK exports are present and valid - fallback only applies to missing/invalid values
  • Backward compatible with no migration required

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-scoped bug fix with defensive fallback logic, comprehensive test coverage, and no breaking changes. The implementation correctly handles edge cases (undefined, null, invalid numeric values) and preserves existing behavior when SDK exports are valid.
  • No files require special attention

Last reviewed commit: 985cb54

@Takhoffman Takhoffman force-pushed the codex/fix-feishu-webhook-default-fallback-31606 branch from 985cb54 to 5ba0224 Compare March 2, 2026 13:40
@Takhoffman Takhoffman merged commit 097ad88 into openclaw:main Mar 2, 2026
20 of 22 checks passed
@Takhoffman
Copy link
Contributor

PR #31639 - fix(feishu): tolerate missing webhook defaults in older plugin-sdk (#31639)

Merged via squash.

Thanks @liuxiaopai-ai!

hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
…penclaw#31639) thanks @liuxiaopai-ai

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
obviyus pushed a commit that referenced this pull request Mar 2, 2026
…31639) thanks @liuxiaopai-ai

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

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

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

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

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
dawi369 pushed a commit to dawi369/davis that referenced this pull request Mar 3, 2026
…penclaw#31639) thanks @liuxiaopai-ai

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

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
…penclaw#31639) thanks @liuxiaopai-ai

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

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
…penclaw#31639) thanks @liuxiaopai-ai

Verified:
- pnpm test extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec vitest run extensions/feishu/src/monitor.state.defaults.test.ts
- pnpm exec oxfmt --check extensions/feishu/src/monitor.state.ts extensions/feishu/src/monitor.state.defaults.test.ts CHANGELOG.md
- CI note: non-required check "check" failed on unrelated  TS errors outside this PR scope.

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: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error Occurred While Configuring Feishu Plugin During OpenClaw Installation and Deployment

2 participants