Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(http): strip JSONC comments from JSON bodies before sending#95

Open
diegoQuinas wants to merge 2 commits into
berbicanes:main from
diegoQuinas:fix/85-jsonc-comments
Open

fix(http): strip JSONC comments from JSON bodies before sending #95
diegoQuinas wants to merge 2 commits into
berbicanes:main from
diegoQuinas:fix/85-jsonc-comments

Conversation

@diegoQuinas

@diegoQuinas diegoQuinas commented Jun 5, 2026

Copy link
Copy Markdown

Closes #85

Summary

  • JSON request bodies that contain 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 made the body start with //, so JSON parsing failed immediately.
  • This strips comments (string-aware) before the body is sent, in both the desktop backend and the CLI.

Changes

File Change
apps/desktop/src-tauri/src/http/jsonc.rs New strip_json_comments (string-aware: preserves // and /* inside JSON strings, honors \ escapes) + unit tests
apps/desktop/src-tauri/src/http/mod.rs Register jsonc module
apps/desktop/src-tauri/src/http/request_builder.rs Strip comments for BodyType::Json before sending
apps/cli/src/jsonc.rs Same helper + tests (no shared crate between desktop and CLI)
apps/cli/src/main.rs Register jsonc module
apps/cli/src/runner.rs Strip comments for json bodies before sending

Test 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 clippy clean, cargo fmt applied

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.

Copy link
Copy Markdown
Author

Fixes #83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Commented JSON not working

1 participant

AltStyle によって変換されたページ (->オリジナル) /