Repository navigation
fix!: answer -32603 when a tools or config file is not a JSON object - #20
Merged
Merged
Conversation
read_json_file guaranteed its file held exactly one parseable JSON document but not that the document was an object, so a file holding `5`, `"x"`, `[1,2]`, `true` or `false` passed the gate. handle_tools_list then ran `.tools // []` on it and handle_initialize handed it to `--argjson config`. Indexing a non-object errors, the empty capture made the `--argjson` inside create_response reject, and create_response is process_request's last command, so its status reached the read loop's `response=$(process_request "$line")` assignment, where errexit is active. The server exited with no response and never read the request that followed (in the default shell mode, with no `set -o posix` involved), while the neighboring missing, empty, multi-document and unparseable files all answer `-32603`. read_json_file now requires the single document to be a JSON object, one gate covering both handlers and validate_tool_arguments. initialize and tools/list answer `-32603` naming the file. A `null` document, which previously read as an empty configuration by accident (indexing `null` yields `null` and jq's `//` took the defaults), answers `-32603` with the rest. BREAKING CHANGE: read_json_file returns 1 for a file whose single document is not a JSON object, initialize and tools/list answer -32603 where a null document previously produced the default configuration and an empty tools list, and validate_tool_arguments' unreadable-list message changed from "is missing or not parseable JSON." to "is missing or does not hold one JSON object.". A consumer whose config and tools files each hold one JSON object sees no change. Fixes #18. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Martin Bens (SpiGAndromeda)
deleted the
fix/read-json-file-object-gate
branch
September 13, 2026 10:50
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.
Closes #18.
What
read_json_fileguaranteed its file held exactly one parseable JSON document but not that the document was an object. A tools or config file holding5,"x",[1,2],trueorfalsepassed the gate;handle_tools_listthen ran.tools // []on it andhandle_initializehanded it to--argjson config. The failed index left an empty capture, the--argjsoninsidecreate_responserejected it, and that status —create_responsebeingprocess_request's last command — reached the read loop'sresponse=$(process_request "$line")assignment, where errexit is active. The server exited with no response, in the default shell mode, while the neighboring missing/empty/multi-document/unparseable files all answer-32603.read_json_filenow requires the single document to be a JSON object — one gate covering both handlers andvalidate_tool_arguments.initializeandtools/listanswer-32603naming the file. Anulldocument, which previously read as an empty configuration by accident, answers-32603with the rest.Breaking (Major per AGENTS.md §Compatibility contract)
read_json_filereturns 1 for a file whose single document is not a JSON object.initialize/tools/listanswer-32603where anulldocument previously produced the default configuration and an empty tools list.validate_tool_arguments' unreadable-list message changed from "is missing or not parseable JSON." to "is missing or does not hold one JSON object.".A consumer whose config and tools files each hold one JSON object sees no change.