fix: use JSON5 parser for plugin manifest loading (#57734) [AI-assisted]#59084
Conversation
Greptile SummaryThis PR fixes a real plugin installation failure by replacing Key changes:
The scope is precisely right — only the reading path is touched; serialization ( Confidence Score: 5/5Safe to merge — minimal, backward-compatible fix using an existing dependency, well-tested, and tightly scoped. All findings are P2 (a minor test-coverage suggestion). The production code change is a single-line substitution in each of two files, using a library already present in the dependency tree and already used for the main config reader. No serialization, validation, or auth paths are touched. No files require special attention. The bundle-manifest.ts change is not directly covered by the new test file, but it is an identical pattern to the manifest.ts change and is covered by existing bundle-manifest tests. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/plugins/manifest.json5-tolerance.test.ts
Line: 84
Comment:
**Weak "invalid syntax" fixture may pass for wrong reasons**
The string `"not json at all {{{}}"` is rejected by both `JSON.parse` and `JSON5.parse`, so it correctly tests the error path. However, since JSON5 is more permissive, it might be worth adding a fixture that is *valid* JSON5 but *structurally* invalid (e.g. parses to a non-object like `"just a string"` or `42`), to ensure the `isRecord` / structural-validation path also stays exercised under JSON5.
This is a suggestion to improve test coverage completeness, not a bug.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: use JSON5 parser for plugin manifes..." | Re-trigger Greptile |
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…I-assisted] Plugin install fails when a third-party plugin manifest (openclaw.plugin.json) contains JSON5 features such as trailing commas, comments, or unquoted keys. The strict JSON.parse used in loadPluginManifest and loadBundleManifestRaw rejects these files during the config validation step of writeConfigFile, preventing the install from completing. - Replace JSON.parse with JSON5.parse in manifest.ts and bundle-manifest.ts - Add JSON5 tolerance tests covering trailing commas, comments, unquoted keys - Verified zero regression across manifest-registry, bundle-manifest, install, installs, and io.write-config test suites (101 tests pass) AI-assisted: code fix and test generation verified by automated test runs
2c96a0b to
58a4d53
Compare
|
Merged via squash.
Thanks @singleGanghood! |
…I-assisted] (openclaw#59084) Merged via squash. Prepared head SHA: 58a4d53 Co-authored-by: singleGanghood <179357632+singleGanghood@users.noreply.github.com> Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> Reviewed-by: @hxy91819
…I-assisted] (openclaw#59084) Merged via squash. Prepared head SHA: 58a4d53 Co-authored-by: singleGanghood <179357632+singleGanghood@users.noreply.github.com> Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> Reviewed-by: @hxy91819
…I-assisted] (openclaw#59084) Merged via squash. Prepared head SHA: 58a4d53 Co-authored-by: singleGanghood <179357632+singleGanghood@users.noreply.github.com> Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> Reviewed-by: @hxy91819
…I-assisted] (openclaw#59084) Merged via squash. Prepared head SHA: 58a4d53 Co-authored-by: singleGanghood <179357632+singleGanghood@users.noreply.github.com> Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> Reviewed-by: @hxy91819
…I-assisted] (openclaw#59084) Merged via squash. Prepared head SHA: 58a4d53 Co-authored-by: singleGanghood <179357632+singleGanghood@users.noreply.github.com> Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com> Reviewed-by: @hxy91819
Plugin install fails when a third-party plugin manifest (openclaw.plugin.json)
contains JSON5 features such as trailing commas, comments, or unquoted keys.
The strict JSON.parse used in loadPluginManifest and loadBundleManifestRaw
rejects these files during the config validation step of writeConfigFile,
preventing the install from completing.
Summary
@vectorize-io/hindsight-openclawplugin fails withConfig validation failed: plugins: plugin: failed to parse plugin manifest: SyntaxError: Expected double-quoted property name in JSON at position 8912. The plugin'sopenclaw.plugin.jsonmanifest uses JSON5 features (trailing commas) thatJSON.parserejects.JSON.parsewithJSON5.parseinloadPluginManifest(manifest.ts) andloadBundleManifestRaw(bundle-manifest.ts) so plugin manifests can contain trailing commas, comments, and unquoted keys — consistent with how the main config file (openclaw.json) is already parsed.writeConfigFile) still uses strictJSON.stringify. Only the manifest reading path was changed. No changes to config validation logic, merge-patch, or env-preserve paths.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
loadPluginManifest(manifest.ts L273) andloadBundleManifestRaw(bundle-manifest.ts L120) useJSON.parseto readopenclaw.plugin.jsonfiles. This strict parser rejects JSON5 features (trailing commas, comments, unquoted keys) that third-party plugin authors may use. WhenwriteConfigFilecallsvalidateConfigObjectRawWithPlugins, the validation loads all registered plugin manifests — if any manifest fails to parse, the validation returns{ ok: false }and the write throws, blocking plugin installation.io.ts) usesjson5.parseforopenclaw.json, but plugin manifests were always loaded with strictJSON.parse. This inconsistency was introduced when the plugin manifest system was first built and never corrected.@vectorize-io/hindsight-openclaw(a popular memory plugin) shipped a manifest with trailing commas.JSON.stringifycannot produce malformed JSON.Regression Test Plan (if applicable)
src/plugins/manifest.json5-tolerance.test.tsloadPluginManifestsuccessfully parses manifests containing trailing commas, single-line comments, and unquoted property names.loadPluginManifest) that failed, with the exact JSON5 features that caused the issue.manifest-registry.test.tswrites manifests viaJSON.stringify(which never produces JSON5), so the JSON5 path was never exercised.User-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Repro + Verification
Environment
Steps
openclaw plugins install @vectorize-io/hindsight-openclawExpected
Actual (before fix)
Config validation failed: plugins: plugin: failed to parse plugin manifest: SyntaxError: Expected double-quoted property name in JSON at position 8912 (line 219 column 5)Evidence
New test file
manifest.json5-tolerance.test.tspasses 5/5 tests:parses a standard JSON manifest without issues✅parses a manifest with trailing commas✅parses a manifest with single-line comments✅parses a manifest with unquoted property names✅still rejects completely invalid syntax✅Existing tests: 101 tests across
manifest-registry.test.ts,bundle-manifest.test.ts,install.test.ts,installs.test.ts, andio.write-config.test.tsall pass with zero regression.Git hooks ran full
pnpm check(tsgo + oxlint + conflict markers + webhook lint + auth lint) — all passed.Human Verification (required)
openclaw plugins install @vectorize-io/hindsight-openclawrequires the actual plugin package.@vectorize-io/hindsight-openclaw(requires npm access to the package and a live OpenClaw setup).Review Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
id,configSchemachecked). JSON5 only affects syntax tolerance, not semantic validation. JSON5 is already a project dependency used for the main config file.Files changed: