Repository navigation
fix(settings): name the file when settings.json does not parse - #1349
Merged
Merged
Conversation
A global `settings.json` that does not parse is reported with the parser's own text alone, so the diagnostic does not say which file is broken. The message now names the path, in the `<path>: <parse error>` form the Plugins route already uses for pi's settings errors. The file is not moved, renamed or repaired. `settings.json` belongs to pi's `SettingsManager`, which reads and writes the same file: when pi cannot parse it, pi reports the error, leaves the file where it is and skips every write until the user repairs it by hand. Pi Web keeps refusing too, and now says which file the user has to repair. Moving the file aside would let the next write create a fresh `settings.json` holding one key, which pi would read as a valid file with no `defaultModel`, no `enabledModels` and no `packages` — and report no error at all. The error stays a `SyntaxError`, the refusal stays a refusal, and the bytes of an unparsable file stay untouched. Only the message changes; a settings file that is not an object keeps its own message. The new tests cover the reported path, the file left in place with its bytes kept, the refused write, and a valid file read and written as before.
brynne8
force-pushed
the
fix/settings-error-names-the-file
branch
from
October 20, 2026 02:07
de4660b to
f2021ed
Compare
Owner
|
Thanks @brynne8, this is exactly the narrow version I had in mind. Checked on a merge with current Looks good to merge. |
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…#1349) A global `settings.json` that does not parse is reported with the parser's own text alone, so the diagnostic does not say which file is broken. The message now names the path, in the `<path>: <parse error>` form the Plugins route already uses for pi's settings errors. The file is not moved, renamed or repaired. `settings.json` belongs to pi's `SettingsManager`, which reads and writes the same file: when pi cannot parse it, pi reports the error, leaves the file where it is and skips every write until the user repairs it by hand. Pi Web keeps refusing too, and now says which file the user has to repair. Moving the file aside would let the next write create a fresh `settings.json` holding one key, which pi would read as a valid file with no `defaultModel`, no `enabledModels` and no `packages` — and report no error at all. The error stays a `SyntaxError`, the refusal stays a refusal, and the bytes of an unparsable file stay untouched. Only the message changes; a settings file that is not an object keeps its own message. The new tests cover the reported path, the file left in place with its bytes kept, the refused write, and a valid file read and written as before.
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…#1349) A global `settings.json` that does not parse is reported with the parser's own text alone, so the diagnostic does not say which file is broken. The message now names the path, in the `<path>: <parse error>` form the Plugins route already uses for pi's settings errors. The file is not moved, renamed or repaired. `settings.json` belongs to pi's `SettingsManager`, which reads and writes the same file: when pi cannot parse it, pi reports the error, leaves the file where it is and skips every write until the user repairs it by hand. Pi Web keeps refusing too, and now says which file the user has to repair. Moving the file aside would let the next write create a fresh `settings.json` holding one key, which pi would read as a valid file with no `defaultModel`, no `enabledModels` and no `packages` — and report no error at all. The error stays a `SyntaxError`, the refusal stays a refusal, and the bytes of an unparsable file stay untouched. Only the message changes; a settings file that is not an object keeps its own message. The new tests cover the reported path, the file left in place with its bytes kept, the refused write, and a valid file read and written as before.
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…#1349) A global `settings.json` that does not parse is reported with the parser's own text alone, so the diagnostic does not say which file is broken. The message now names the path, in the `<path>: <parse error>` form the Plugins route already uses for pi's settings errors. The file is not moved, renamed or repaired. `settings.json` belongs to pi's `SettingsManager`, which reads and writes the same file: when pi cannot parse it, pi reports the error, leaves the file where it is and skips every write until the user repairs it by hand. Pi Web keeps refusing too, and now says which file the user has to repair. Moving the file aside would let the next write create a fresh `settings.json` holding one key, which pi would read as a valid file with no `defaultModel`, no `enabledModels` and no `packages` — and report no error at all. The error stays a `SyntaxError`, the refusal stays a refusal, and the bytes of an unparsable file stay untouched. Only the message changes; a settings file that is not an object keeps its own message. The new tests cover the reported path, the file left in place with its bytes kept, the refused write, and a valid file read and written as before.
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.
What it does
A global
settings.jsonthat does not parse is now reported with the path of the file in front of the parser's message:(The parser's own text is Node's, and its wording differs between Node versions; the path in front of it does not.)
The refusal is unchanged — the file is still left exactly where it is, its bytes untouched, and every write against it is still refused until the user repairs it by hand. Only the text of the diagnostic changes, and it now follows the
<path>: <parse error>form the Plugins route already uses for pi's settings errors.Every caller built on the module surfaces the message unchanged:
/api/tools/settingsand/api/cache-miss-noticesin their 500 body, the MCP listing aspreferenceError,modeErrorandinlineBudgetError.Why it matters
On
mainthe diagnostic is the parser's text alone, with no path in it. Settings › General's switch and Settings › MCP's Code mode, PowerShell and tool-list-budget switches show that text and nothing else, so the user is told that a file is broken but not which one — andsettings.jsonis the file pi itself writes, so it is the one most likely to be edited by hand.This is the part of the earlier attempt that fits upstream. In the closing comment on #1327, the maintainer wrote:
This is that PR: the refusal stays, and the path goes into the error.
Reproduction
On
main:The message never says which file is broken.
On this branch the same three requests answer with the same refusals and the same text, prefixed by the path:
Scope
One change: the path is added to the parse error. The file is not moved, renamed, backed up or repaired; the refusal stays a refusal; the error stays a
SyntaxError; a settings file that parses to something other than an object keeps its own message.lib/global-settings-file.tsis the whole implementation, pluslib/global-settings-file.test.mjs, which is new and pins the reported path, the file left in place with its bytes kept, the refused write, and a valid file read and written as before. Nothing else in the tree changes: the readers and writers already surface the message they are thrown, and no user-visible string is added — the text is the English server diagnostic the panels already show for aninternalfailure.Deliberately not done: no recovery path. Pi Web does not move, rename, back up or rewrite the file, does not offer to repair it, and does not start writing to it again.
settings.jsonis pi's file as much as Pi Web's — pi'sSettingsManagerreads and writes it, and pi's own contract on an unparsable file is to report the error, leave the file in place and skip every write until the user fixes it. Pi Web keeps that contract, and only makes the message actionable by naming the file the user has to repair.Testing
lib/global-settings-file.test.mjsis new and covers the four cases directly. The existing assertions inlib/codemode-settings.test.mjs,app/api/tools/settings/route.test.mjsandapp/api/mcp/route.test.mjs—SyntaxErrorout of the writers, the corrupt bytes still atsettingsPath,refusal.errormatching/JSON/— still hold and were not changed.Provenance
Split out of a Bun-running fork (
brynne8/pi-web-bun) into a single-purpose branch on today'smain; one feature per PR.The behaviour was written for this branch rather than taken from the earlier attempt: the earlier one moved the file aside, which upstream declined for the reasons quoted above. Here the file stays, and only the message changes.