-
Notifications
You must be signed in to change notification settings - Fork 57
fix(http): strip JSONC comments from JSON bodies before sending#95
Open
diegoQuinas wants to merge 2 commits into
Open
fix(http): strip JSONC comments from JSON bodies before sending #95diegoQuinas wants to merge 2 commits into
diegoQuinas wants to merge 2 commits into
Conversation
JSON request bodies with JSONC-style comments (`// ...` and `/* */`) were sent to the server verbatim. A trailing comment happened to work when the server tolerated trailing data, but a leading comment line made the body start with `//`, so parsing failed immediately (issue berbicanes#85). Add a string-aware `strip_json_comments` that removes comments while preserving markers inside string values, and apply it to JSON bodies in both the desktop backend and the CLI runner. Closes berbicanes#85
The Monaco JSON language service defaults to `comments: "error"`, so `//` and `/* */` lines in a JSON body were underlined with a red error squiggle. Now that comments are stripped before sending, they are valid editor input — set the JSON diagnostics to ignore comments while keeping the rest of JSON validation intact.
diegoQuinas
commented
Jun 5, 2026
Author
Fixes #83
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 #85
Summary
// ...and/* */) were sent to the server verbatim.//, so JSON parsing failed immediately.Changes
apps/desktop/src-tauri/src/http/jsonc.rsstrip_json_comments(string-aware: preserves//and/*inside JSON strings, honors\escapes) + unit testsapps/desktop/src-tauri/src/http/mod.rsjsoncmoduleapps/desktop/src-tauri/src/http/request_builder.rsBodyType::Jsonbefore sendingapps/cli/src/jsonc.rsapps/cli/src/main.rsjsoncmoduleapps/cli/src/runner.rsTest Plan
cargo test— 8 unit tests per crate, all passing (leading/trailing line comments, block comments, markers preserved inside strings, escaped quote/backslash before closing quote, plain JSON untouched)cargo clippyclean,cargo fmtapplied