Repository navigation
fix(ui): say where plugin.json is malformed when a plugin folder is refused (#725) - #730
Open
leninworld wants to merge 1 commit into
Open
leninworld wants to merge 1 commit into
leninworld wants to merge 1 commit into
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #725.
The bug
Installing a plugin package from a folder (Settings › Capabilities › Plugins) parses the folder's
plugin.jsonin the browserbefore anything is sent. When that file is malformed,
installFolderinui/src/components/hrui/setup/SetupSettings.tsxcaughtthe
SyntaxErrorand threw a freshError('Its plugin.json is not valid JSON.'). The parser's message was dropped, so everymalformation (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,
parsePluginManifestinui/src/components/hrui/setup/pluginManifest.ts, replaces the inline parse. It keeps theexisting sentence unchanged ("Its plugin.json is not valid JSON.") and follows it with the parser's message, with the original
SyntaxErrorattached as the error'scause. The toast still showse.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.tsxpicks folders through thesettings' own folder input. Run against the unchanged
SetupSettings.tsxat93994cf, its two notice tests fail on theirassertions ("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.tschecks that the cause is the exactSyntaxErrorthe parser threw, that the sentence is keptwith 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'scommit:
npm ci,npm run type-check,npm test(158/158 suites, 1708/1708 tests: the 156 suites and 1700 tests at93994cfplusthese 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.jsonis{"name": "x"(closing brace missing) shows, in Chromium 156 (cropped to the Plugins panel):Not run: Windows, and a container-level image build. Only the console changed; no gateway, protocol or install change.