Skip to content

fix(matrix): add idempotency guard to prevent duplicate registration (fixes #52780)#3

Open
ywxc1997 wants to merge 3785 commits intomainfrom
fix/matrix-redefine-property-52780
Open

fix(matrix): add idempotency guard to prevent duplicate registration (fixes #52780)#3
ywxc1997 wants to merge 3785 commits intomainfrom
fix/matrix-redefine-property-52780

Conversation

@ywxc1997
Copy link
Copy Markdown
Owner

Summary

This PR fixes the "TypeError: Cannot redefine property: resolveMatrixAccountStringValues" error that occurs when loading the Matrix plugin in bundled builds.

Root Cause

The error occurs because the Matrix plugin is being loaded twice:

  1. Through the setup entry point (setup-entry.ts)
  2. Through the main plugin entry point (index.ts)

In bundled builds (tsdown), this can cause the module to be initialized twice, leading to the "Cannot redefine property" error.

Fix

Added idempotency guards in both entry files:

  1. index.ts: Added isRegistered flag to guard against duplicate registerFull() calls
  2. setup-entry.ts: Added setupInitialized flag to guard against duplicate setup() calls

Both guards log when skipping duplicate initialization.

Testing

  • The plugin should now load without the TypeError
  • Duplicate initialization attempts will be logged but safely skipped

Fixes: openclaw#52780

steipete and others added 30 commits March 22, 2026 23:01
steipete and others added 29 commits March 23, 2026 16:13
Signed-off-by: sallyom <somalley@redhat.com>
…anks @BunsDev

Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
Co-authored-by: Nova <nova@openknot.ai>
…ntrol-char injection

- Use hasOwnProperty + isBlockedObjectKey in isConfiguredAuthPlugin to
  prevent __proto__/constructor/prototype keys from matching config
- Sanitize plugin IDs with sanitizeForLog in ambiguity error messages
- Add regression test for __proto__ plugin ID
OPENCLAW_PLUGIN_API_VERSION was hardcoded to "1.2.0" while ClawHub-published
plugins require >=2026.3.22, making all plugin installs via ClawHub fail with
"requires plugin API >=2026.3.22, but this OpenClaw runtime exposes 1.2.0".

Use resolveRuntimeServiceVersion() (already imported) to read the actual
version from package.json at runtime.

Fixes openclaw#53038
…penclaw#53272) thanks @BunsDev

Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
Co-authored-by: Nova <nova@openknot.ai>
Use isSensitiveConfigPath to detect token/password/secret/apiKey paths
and display REDACTED_PLACEHOLDER instead of raw values in the config
diff panel, preventing credential exposure in the UI.
This fix addresses the 'Cannot redefine property: resolveMatrixAccountStringValues'
error that occurs in bundled builds due to the plugin being loaded multiple times
through both the setup entry and the main plugin entry.

Changes:
- Add isRegistered flag in index.ts to guard against duplicate registerFull() calls
- Add setupInitialized flag in setup-entry.ts to guard against duplicate setup() calls
- Both guards log when skipping duplicate initialization

Fixes: openclaw#52780
@ywxc1997 ywxc1997 force-pushed the fix/matrix-redefine-property-52780 branch from 21a7bf3 to 1d87f4b Compare March 24, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Matrix TypeError: Cannot redefine property: resolveMatrixAccountStringValues