Skip to content

Fix legacy plugin JSON import validation#4690

Open
roboomp wants to merge 1 commit into
mainfrom
farm/8581e25d/plugin-json-import-attributes
Open

Fix legacy plugin JSON import validation#4690
roboomp wants to merge 1 commit into
mainfrom
farm/8581e25d/plugin-json-import-attributes

Conversation

@roboomp

@roboomp roboomp commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Repro

A minimal legacy plugin entry that imports ./data.json with with { type: "json" } reproduced the failure through loadLegacyPiModule() with bun /tmp/omp-json-import-repro.ts: before the fix, Bun raised BuildMessage: Expected ";" but found ":" because the compat graph hook served the JSON file as JavaScript.

Cause

packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.ts collected every relative Bun.resolveSync() target into the extension rewrite graph. That included .json files, so installExtensionGraphHook() intercepted the JSON module and getLoader() fell back to "js", forcing Bun's per-module parser to parse raw JSON instead of using the native JSON loader.

Fix

  • Filter relative extension graph targets through hasSourceModuleExtension() before registering them with the rewrite hook.
  • Apply the same source-module filter to extension-local bare dependency entries so non-source assets stay on Bun's native loaders.
  • Add a loadLegacyPiModule() regression test for a temp extension importing JSON with with { type: "json" }.
  • Add a coding-agent changelog entry for the plugin validation fix.

Verification

bun /tmp/omp-json-import-repro.ts now prints { "value": true }; bun test packages/coding-agent/test/extensibility/legacy-pi-inplace-load.test.ts -t 'leaves JSON import-attribute targets on Bun' passed with 1 test; bun check passed; bun run fix reported no fixes needed before commit. Fixes #4687

- Left JSON files imported with import attributes on Bun's native loader instead of registering them with the legacy source rewrite hook.
- Added a regression test for loadLegacyPiModule loading a JSON import-attribute target.

Fixes #4687
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouched Passed the vouch gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin extension validator fails on `with { type: "json" }" import attributes (7 errors building .json)

1 participant