fix: don't crash uninstall on malformed settings.json (#434)#481
Merged
Conversation
If settings.json contained invalid JSON, JSON.parse threw a SyntaxError, which has no .code, so the catch rethrew it and crashed the script — after the mode flag and config file were already removed, leaving cleanup half-done. Handle SyntaxError explicitly: warn that the statusLine entry couldn't be removed and leave the file untouched, since invalid JSON can't be safely edited. Adds a regression test that a malformed settings.json exits 0, warns, and is left byte-for-byte intact. Closes #434 Co-authored-by: isaukywhite <50426537+isaukywhite@users.noreply.github.com>
This was referenced Jul 1, 2026
github-actions Bot
pushed a commit
to harshav167/ponytail
that referenced
this pull request
Jul 2, 2026
…#481) If settings.json contained invalid JSON, JSON.parse threw a SyntaxError, which has no .code, so the catch rethrew it and crashed the script — after the mode flag and config file were already removed, leaving cleanup half-done. Handle SyntaxError explicitly: warn that the statusLine entry couldn't be removed and leave the file untouched, since invalid JSON can't be safely edited. Adds a regression test that a malformed settings.json exits 0, warns, and is left byte-for-byte intact. Closes DietrichGebert#434 Co-authored-by: isaukywhite <50426537+isaukywhite@users.noreply.github.com>
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.
Problem
Closes #434. In
scripts/uninstall.js, a malformedsettings.jsonmakesJSON.parsethrow aSyntaxError, which has no.code, soif (e.code !== 'ENOENT') throw erethrew it and crashed the script — after the mode flag and config file were already removed, leaving cleanup half-done.Reproduced on current main: with a malformed settings.json the script exits non-zero with an uncaught SyntaxError, after
.ponytail-activewas already deleted.Fix
Handle
SyntaxErrorexplicitly in the catch: warn that the statusLine entry couldn't be removed and leave the file untouched (invalid JSON can't be safely edited), then exit 0. ENOENT stays a no-op; any other error still rethrows.Verification
npm test: 70 + 15 pass, exit 0.check-rule-copies/check-versions: exit 0.Note
Supersedes #469 (same fix by @isaukywhite, credited as co-author), which branched before #479 (combined-statusline guard) and #480 landed and so conflicts on both changed files. This reconciles the identical fix onto current main. Suggest closing #469 in favor of this. (#471 is a separate packaging concern, not touched here.)