Skip to content

fix(ui): say where plugin.json is malformed when a plugin folder is refused (#725) - #730

Open
leninworld wants to merge 1 commit into
HarnessRouter:mainfrom
leninworld:fix-plugin-json-parse-error-issue-725
Open

leninworld wants to merge 1 commit into
HarnessRouter:mainfrom
leninworld:fix-plugin-json-parse-error-issue-725

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

This PR fixes issue #725.

The bug

Installing a plugin package from a folder (Settings › Capabilities › Plugins) parses the folder's plugin.json in the browser
before anything is sent. When that file is malformed, installFolder in ui/src/components/hrui/setup/SetupSettings.tsx caught
the SyntaxError and threw a fresh Error('Its plugin.json is not valid JSON.'). The parser's message was dropped, so every
malformation (a missing comma, a trailing comma, a stray quote) showed the same notice and gave no position to fix.

Expected behavior

The notice still says the manifest is not valid JSON, and it also says where and why, using the parser's own message. Two different
mistakes read differently. A malformed file is still refused before anything is saved, and a valid package installs exactly as before.

The fix

A small helper, parsePluginManifest in ui/src/components/hrui/setup/pluginManifest.ts, replaces the inline parse. It keeps the
existing sentence unchanged ("Its plugin.json is not valid JSON.") and follows it with the parser's message, with the original
SyntaxError attached as the error's cause. The toast still shows e.message, so nothing else in the install flow changes.
The expected parser text is computed in the tests rather than hard-coded, because engines word it differently.

Verification

  • Fails before, passes after. ui/src/components/hrui/setup/SetupSettings.pluginFolder.test.tsx picks folders through the
    settings' own folder input. Run against the unchanged SetupSettings.tsx at 93994cf, its two notice tests fail on their
    assertions ("a malformed plugin.json is refused with the parser's own message", "two different malformations give two different
    notices"). "A malformed plugin.json is never saved" and "a valid plugin.json still installs" pass there too. With the fix, all four pass.

  • Helper tests. pluginManifest.test.ts checks that the cause is the exact SyntaxError the parser threw, that the sentence is kept
    with its period, that two malformations read differently, and that a valid manifest comes back as written.

  • Console checks from CONTRIBUTING, run in Docker on Node 20.20.2 (node:20.20.2-bookworm, linux/amd64) on this branch's
    commit: npm ci, npm run type-check, npm test (158/158 suites, 1708/1708 tests: the 156 suites and 1700 tests at 93994cf plus
    these 2 suites and 8 tests), npm run build, both licence checks, and the third-party licence list (node scripts/third-party-licenses.mjs). All passed.

  • In the real console. The built console was served with the gateway from this branch (self-hosted, auth disabled, loopback only).
    Choosing a folder whose plugin.json is {"name": "x" (closing brace missing) shows, in Chromium 156 (cropped to the Plugins panel):

    Corrected plugin.json notice

Not run: Windows, and a container-level image build. Only the console changed; no gateway, protocol or install change.

…efused (HarnessRouter#725)

Installing a plugin package from a folder parses its plugin.json first, and a
malformed one was refused with the fixed sentence alone: the parser's error was
caught and dropped, so every mistake read the same and the position was lost.

The manifest is now read by parsePluginManifest (setup/pluginManifest.ts), which
keeps the sentence "Its plugin.json is not valid JSON." and follows it with the
parser's own message, with the SyntaxError as the error's cause. Nothing else in
the install changes: a malformed file is still refused before anything is saved.

Tests: pluginManifest.test.ts checks the cause is the exact SyntaxError and the
sentence is unchanged; SetupSettings.pluginFolder.test.tsx picks folders through
the settings' own folder input and checks the notice, that two malformations
read differently, that nothing is saved, and that a valid package still installs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
unified-harness-protocol Ready Ready Preview Nov 21, 2026 6:13am UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — ea89e51e Deployed Nov 21, 2026 by vercel[bot]
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.

The console discards the parse error when plugin.json is not valid JSON

1 participant