Repository navigation
fix: updates fail when plugin inspection retains import.meta - #155394
Conversation
Admit retained module syntax in transformed plugin source without imposing ESM strictness on CommonJS. Record candidate rehearsal parse failures as named plugin warnings and reuse inspected dependency graphs while preserving integrity checks. Release-note context: Updates driven by older releases can complete candidate Doctor rehearsal when plugin transforms retain import.meta. Thanks @colehammond65 for the detailed report in #155371.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 22, 2026, 1:56 AM ET / 05:56 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR lets plugin dependency inspection accept retained import.meta, turns individual parse failures into named warnings, and reuses inspected dependency graphs. Merge readiness⛔ Blocked before merge - 1 item remains The fix remains necessary and has convincing upgrade evidence. No actionable defect was found; the previous generic migration-proof blocker does not apply to this patch. Priority: P0 Review scores
Verification
How this fits togetherBefore activating an update, candidate Doctor checks plugins in a private rehearsal copy. Dependency inspection identifies missing files for repair and reports warnings while preserving the existing source-integrity checks. flowchart TD
A[Installed updater] --> B[Private rehearsal copy]
B --> C[Candidate Doctor]
C --> D[Plugin source inspection]
D --> E{Source parses}
E -->|Yes| F[Check integrity and repair dependencies]
E -->|No| G[Report plugin warning]
F --> H[Continue candidate validation]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +50, Docs +3. Total +79 across 6 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep candidate-side inspection compatible with valid ESM and report isolated plugin parse failures without interrupting otherwise safe updates. Do we have a high-confidence way to reproduce the issue? Yes: current-main parser settings and Acorn's implementation establish the retained-import.meta failure path, backed by the supplied published-release reproduction; this review did not execute it. Is this the best way to solve the issue? Yes: the repair uses the existing inspection and rehearsal owners, preserves CommonJS parsing semantics, and is backed by a published-updater upgrade run. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4d50b52bce2b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…w#155394) * fix: updates fail when plugin inspection retains import.meta Admit retained module syntax in transformed plugin source without imposing ESM strictness on CommonJS. Record candidate rehearsal parse failures as named plugin warnings and reuse inspected dependency graphs while preserving integrity checks. Release-note context: Updates driven by older releases can complete candidate Doctor rehearsal when plugin transforms retain import.meta. Thanks @colehammond65 for the detailed report in openclaw#155371. * style: avoid spread in plugin dependency aggregation
….meta.url (#157862) ## What Problem This Solves Fixes: `openclaw update` stops with `Update state snapshot failed (exit): Assigning to rvalue (308:4)` when an installed plugin depends on valid JavaScript that assigns to `import.meta.url`. The error names no file, so the user cannot tell which dependency blocks the update. A real trigger is `@jsquash/[email protected]` (`codec/pkg/squoosh_png.js`), reached through a literal dynamic import: ```js if (import.meta.url === undefined) { import.meta.url = 'https://localhost'; } ``` Related: #146993 (added the native scan path), #155394 (earlier `import.meta` inspection fix). ## User Impact Updates no longer stop for plugins whose dependencies assign to `import.meta` properties, such as `@jsquash/png` and `@jsquash/avif`. If plugin source inspection still cannot parse a file, the updater error now names that file and says the failure happened after the source transform. Upgrade path: the installed updater runs the snapshot inspection itself. Installs that already run 2026.9.5 or 2026.9.6 keep the old inspection for the update that moves them to this fix, so that one update can still stop on such a plugin. The update troubleshooting page now documents the recovery for that one update: `openclaw plugins disable <id>`, `openclaw update`, then `openclaw plugins enable <id>`. Updates from releases before 2026.9.5 do not run this inspection in the snapshot. All later updates use the fixed inspection. ## Why This Change Was Made - Plugin source inspection sends JavaScript that uses `import.meta` through the Jiti transform, so Jiti can rewrite reference anchors such as `import.meta.dirname` and `import.meta.resolve(...)`. Jiti also replaces `import.meta.url` with a string literal on the left side of an assignment. The output is then not valid JavaScript, and the parser rejects it. - Before the transform, inspection now replaces an `import.meta.*` expression that receives a value (plain or compound assignment, update, destructuring, `for…in`/`for…of` target) with a plain identifier. The transform output is used only to find references and is never executed, so imports, `new URL(..., import.meta.url)` assets and `import.meta.dirname` anchors are still traced as before. The dependency is inspected, not skipped. - The fix is in the transform path and not in the native fast path. Other syntax can also select the transform (for example `for (key in object)` in the `@jsquash/avif` encoder), so a native-only fix would still fail on that sibling file. - If the transformed output still cannot be parsed, inspection now throws a `SyntaxError` that names the source file and the stage, and keeps the parser error as `cause`. Callers that already catch `SyntaxError` (candidate rehearsal warnings) keep their behavior. ## Evidence Real `openclaw update --tag <future tarball> --yes --no-restart --json`, run in a disposable container with a throwaway profile. The profile has one path-loaded plugin that lazily imports `@jsquash/[email protected]/encode.js` and `@jsquash/[email protected]/encode.js` (the published packages, unmodified). | Installed updater | Update target | Result | | --- | --- | --- | | `main` (base of this PR) | base + version bump | exit 1: `Update state snapshot failed (exit): Assigning to rvalue (308:4)` | | this PR | this PR + version bump | exit 0, updated, only the normal advisory for a `plugins.load.paths` plugin | | published 2026.9.6 | this PR + version bump | exit 1: same `Assigning to rvalue (308:4)` (the installed updater runs its own inspection; see User Impact) | | published 2026.7.35 | this PR + version bump | exit 0, updated | | published 2026.9.6, plugin disabled first (documented recovery) | this PR + version bump | exit 0, updated; `openclaw plugins enable` and `plugins inspect` then succeed | The scanner on the exact dependency files: | File | Before | After | | --- | --- | --- | | `@jsquash/png` `codec/pkg/squoosh_png.js` | `SyntaxError: Assigning to rvalue (308:4)` | ok, asset `squoosh_png_bg.wasm` traced | | `@jsquash/avif` `codec/enc/avif_enc.js` | `SyntaxError: Assigning to rvalue (8:900)` | ok, asset `avif_enc.wasm` traced | | `@jsquash/avif` `codec/enc/avif_enc_mt.js` | `SyntaxError: Assigning to rvalue (8:1752)` | ok, assets `avif_enc_mt.wasm` and `avif_enc_mt.worker.mjs` traced | Focused tests: - New `plugin-generation-source-inspection` cases fail on base (`Assigning to rvalue (4:2)`, and the parse error has no file name) and pass with the fix. The first case also checks that the dynamic import, the static import, `import.meta.resolve(...)`, the `new URL(..., import.meta.url)` asset and the `import.meta.dirname` asset are still traced. - `plugin-generation-source-inspection`, `plugin-generation-artifact`, `plugin-module-generation`, `plugin-module-generation.sibling-assets`, `update-candidate-plugin-repair`, `update-candidate-plugin-sources`: 205 tests pass. - Test cost: `pnpm test src/plugins/plugin-generation-source-inspection.test.ts --maxWorkers=1` runs in 2.2 s (5.0 s wall with startup); the two new cases take 30 ms and 7 ms. In CI (`checks-node-changed`) the file takes 3.1 s from shard begin to end (Vitest duration 1.98 s); the new cases take 33 ms and 6 ms. Co-authored-by: Ayaan Zaidi <[email protected]>
….meta.url (openclaw#157862) ## What Problem This Solves Fixes: `openclaw update` stops with `Update state snapshot failed (exit): Assigning to rvalue (308:4)` when an installed plugin depends on valid JavaScript that assigns to `import.meta.url`. The error names no file, so the user cannot tell which dependency blocks the update. A real trigger is `@jsquash/[email protected]` (`codec/pkg/squoosh_png.js`), reached through a literal dynamic import: ```js if (import.meta.url === undefined) { import.meta.url = 'https://localhost'; } ``` Related: openclaw#146993 (added the native scan path), openclaw#155394 (earlier `import.meta` inspection fix). ## User Impact Updates no longer stop for plugins whose dependencies assign to `import.meta` properties, such as `@jsquash/png` and `@jsquash/avif`. If plugin source inspection still cannot parse a file, the updater error now names that file and says the failure happened after the source transform. Upgrade path: the installed updater runs the snapshot inspection itself. Installs that already run 2026.9.5 or 2026.9.6 keep the old inspection for the update that moves them to this fix, so that one update can still stop on such a plugin. The update troubleshooting page now documents the recovery for that one update: `openclaw plugins disable <id>`, `openclaw update`, then `openclaw plugins enable <id>`. Updates from releases before 2026.9.5 do not run this inspection in the snapshot. All later updates use the fixed inspection. ## Why This Change Was Made - Plugin source inspection sends JavaScript that uses `import.meta` through the Jiti transform, so Jiti can rewrite reference anchors such as `import.meta.dirname` and `import.meta.resolve(...)`. Jiti also replaces `import.meta.url` with a string literal on the left side of an assignment. The output is then not valid JavaScript, and the parser rejects it. - Before the transform, inspection now replaces an `import.meta.*` expression that receives a value (plain or compound assignment, update, destructuring, `for…in`/`for…of` target) with a plain identifier. The transform output is used only to find references and is never executed, so imports, `new URL(..., import.meta.url)` assets and `import.meta.dirname` anchors are still traced as before. The dependency is inspected, not skipped. - The fix is in the transform path and not in the native fast path. Other syntax can also select the transform (for example `for (key in object)` in the `@jsquash/avif` encoder), so a native-only fix would still fail on that sibling file. - If the transformed output still cannot be parsed, inspection now throws a `SyntaxError` that names the source file and the stage, and keeps the parser error as `cause`. Callers that already catch `SyntaxError` (candidate rehearsal warnings) keep their behavior. ## Evidence Real `openclaw update --tag <future tarball> --yes --no-restart --json`, run in a disposable container with a throwaway profile. The profile has one path-loaded plugin that lazily imports `@jsquash/[email protected]/encode.js` and `@jsquash/[email protected]/encode.js` (the published packages, unmodified). | Installed updater | Update target | Result | | --- | --- | --- | | `main` (base of this PR) | base + version bump | exit 1: `Update state snapshot failed (exit): Assigning to rvalue (308:4)` | | this PR | this PR + version bump | exit 0, updated, only the normal advisory for a `plugins.load.paths` plugin | | published 2026.9.6 | this PR + version bump | exit 1: same `Assigning to rvalue (308:4)` (the installed updater runs its own inspection; see User Impact) | | published 2026.7.35 | this PR + version bump | exit 0, updated | | published 2026.9.6, plugin disabled first (documented recovery) | this PR + version bump | exit 0, updated; `openclaw plugins enable` and `plugins inspect` then succeed | The scanner on the exact dependency files: | File | Before | After | | --- | --- | --- | | `@jsquash/png` `codec/pkg/squoosh_png.js` | `SyntaxError: Assigning to rvalue (308:4)` | ok, asset `squoosh_png_bg.wasm` traced | | `@jsquash/avif` `codec/enc/avif_enc.js` | `SyntaxError: Assigning to rvalue (8:900)` | ok, asset `avif_enc.wasm` traced | | `@jsquash/avif` `codec/enc/avif_enc_mt.js` | `SyntaxError: Assigning to rvalue (8:1752)` | ok, assets `avif_enc_mt.wasm` and `avif_enc_mt.worker.mjs` traced | Focused tests: - New `plugin-generation-source-inspection` cases fail on base (`Assigning to rvalue (4:2)`, and the parse error has no file name) and pass with the fix. The first case also checks that the dynamic import, the static import, `import.meta.resolve(...)`, the `new URL(..., import.meta.url)` asset and the `import.meta.dirname` asset are still traced. - `plugin-generation-source-inspection`, `plugin-generation-artifact`, `plugin-module-generation`, `plugin-module-generation.sibling-assets`, `update-candidate-plugin-repair`, `update-candidate-plugin-sources`: 205 tests pass. - Test cost: `pnpm test src/plugins/plugin-generation-source-inspection.test.ts --maxWorkers=1` runs in 2.2 s (5.0 s wall with startup); the two new cases take 30 ms and 7 ms. In CI (`checks-node-changed`) the file takes 3.1 s from shard begin to end (Vitest duration 1.98 s); the new cases take 33 ms and 6 ms. Co-authored-by: Ayaan Zaidi <[email protected]>
…rrors (#162298) The candidate state snapshot step launched its worker from the installed driver's own dist instead of the candidate root, so an old driver parsed plugin bundles with pre-#155394 options and failed the whole snapshot on an ESM plugin's import.meta ("Cannot use 'import.meta' outside a module"), ending the update as runtime-verification-failed. The snapshot worker now resolves under candidateRoot, and an unparseable plugin is recorded as a bounded named warning through the inspection helper Doctor already shares, instead of aborting the snapshot. Already-installed 2026.9.5/9.6 drivers keep their old worker for that first hop; the issue records the disable/update/enable recovery. Closes #162017
…rrors (openclaw#162298) The candidate state snapshot step launched its worker from the installed driver's own dist instead of the candidate root, so an old driver parsed plugin bundles with pre-openclaw#155394 options and failed the whole snapshot on an ESM plugin's import.meta ("Cannot use 'import.meta' outside a module"), ending the update as runtime-verification-failed. The snapshot worker now resolves under candidateRoot, and an unparseable plugin is recorded as a bounded named warning through the inspection helper Doctor already shares, instead of aborting the snapshot. Already-installed 2026.9.5/9.6 drivers keep their old worker for that first hop; the issue records the disable/update/enable recovery. Closes openclaw#162017
…rrors (openclaw#162298) The candidate state snapshot step launched its worker from the installed driver's own dist instead of the candidate root, so an old driver parsed plugin bundles with pre-openclaw#155394 options and failed the whole snapshot on an ESM plugin's import.meta ("Cannot use 'import.meta' outside a module"), ending the update as runtime-verification-failed. The snapshot worker now resolves under candidateRoot, and an unparseable plugin is recorded as a bounded named warning through the inspection helper Doctor already shares, instead of aborting the snapshot. Already-installed 2026.9.5/9.6 drivers keep their old worker for that first hop; the issue records the disable/update/enable recovery. Closes openclaw#162017 (cherry picked from commit f525f46)
Closes #155371
What Problem This Solves
Fixes upgrades that stop during candidate migration rehearsal when plugin source transformation retains
import.meta.User Impact
Valid ESM plugins no longer abort candidate Doctor inspection. Unparseable entries produce warnings naming the plugin, source path, and parser error while other entries continue. Source-integrity and private-state checks remain enforced.
Release-note context: This candidate-side repair works with already installed updaters, including 2026.9.4, without new options or configuration changes. Thanks @colehammond65 for the detailed report.
Why This Change Was Made
Acorn parsed Jiti's mixed ESM/CommonJS output as a script. Admit retained module syntax without imposing strict ESM semantics on CommonJS, contain per-entry syntax errors, and reuse inspected dependency graphs instead of rescanning them.
The reporter's exact plugin remains unidentified. The fix covers every plugin whose transformed entry retains
import.meta. A synthetic plugin reproduces the exact published 9.5 Doctor crash at(1203:16): Jiti preserves line 1203 while formatting shifts the token from source column 14 to column 16.Evidence
check:changedpassed in 1,412 seconds, including all 25 test-type shards, production types, lint, dead-export scans, and every selected guard. The initialno-map-spreadlint finding was fixed with equivalent array concatenation; the complete corrected gate passed.pnpm buildpassed in 5m 26.5s. The candidate tarball passed inventory and import-graph integrity checks.openclaw update: exit 0 in 64.603 seconds, withstatus: okandrun.status: succeeded. Candidate Doctor, lint, config validation, plugin resolution, migration continuation, Gateway canary, and post-update Doctor all exited 0.Published-driver warning and artifact provenance
Both fixture entries contain retained
import.metaat transformed position(1203:16). The valid entry is accepted. The malformed sibling reaches its independent regex error on the next line and produces a warning.Final head:
e5d95712db3b46081887a96b33eef2c99d76aef7. Its tree67c16cbe288b3c5b88a83016cdd4a554a299fb5fexactly matches the source tree verified by both Testbox lanes, including the one-line lint correction.Candidate SHA-256:
fb309da230459b8c08610158a1fcca1981f87a273be3b334b65841679cf1d22e.tbx_01m33kx44pydtd94qmxf5cw7yb, run 35684762044.tbx_01m33kvj2cekjt5gk05cehkn3j, run 35684710463.Both proof commands exited 0. Both leases were stopped after evidence collection.