Skip to content

Fix empty commented arrays in legacy Reader - #1719

Open
vaibhav0806 wants to merge 2 commits into
open-source-parsers:masterfrom
vaibhav0806:fix/legacy-empty-array-comments-1238
Open

vaibhav0806 wants to merge 2 commits into
open-source-parsers:masterfrom
vaibhav0806:fix/legacy-empty-array-comments-1238

Conversation

@vaibhav0806

@vaibhav0806 vaibhav0806 commented Oct 1, 2026 •

Copy link
Copy Markdown

Fixes #1238.

With comments enabled, legacy Json::Reader rejects {"list":[ //\n]} and leaves a partial array containing null. CharReader already accepts the same document as an empty array.

Consume allowed line/block comment tokens before the legacy reader's initial empty-array delimiter check, so it does not create element zero before discovering ]. Use the existing error recovery for malformed comments. Add four regression fixtures covering root/nested arrays, collection on/off, comments disallowed, unterminated comments, ordinary element/container comments, and offsets.

Only Reader::readArray and its tests change. Public headers, declarations and class layout are unchanged. Modern parsing, numeric conversion, trailing-comma handling and comment storage are unchanged.

Local validation on macOS arm64, Apple Clang 17, C++11, Debug, default configuration and static library:

  • All 3 CTests pass, including 135 unit tests. The new regression fixture fails when linked against the original library; the original example now succeeds for both reader APIs with array size zero.
  • A 152-case legacy comparison covers comment and dropped-null settings: 136 controls are identical, 12 target combinations become empty arrays, and 4 malformed-comment combinations remain errors but avoid the partial null element. Collected comment text is retained. Numeric and modern-reader probe results are unchanged.
  • The original and patched static libraries have the same 2,108 external symbol names; this is not a formal cross-platform dynamic ABI audit.
  • git diff --check and clang-format 17/20 checks pass; both formatters produce identical output for the changed files.

The seven upstream workflows currently await maintainer approval on head 167330d624e203b35d4df35a33b935f04f810bea; no jobs or checks have run. Exact clang-format 18, Linux/Windows/shared-library builds and other language standards remain unverified. cppcheck was unavailable locally, so no static-analysis success is claimed.

Prepared with AI assistance. The generated diff was independently checked and the local validation was run by an automated agent. No human review is claimed.

@vaibhav0806
vaibhav0806 marked this pull request as ready for review October 1, 2026 07:21
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Fixes legacy Reader parsing of empty arrays containing comments.

  • Commented empty arrays stay empty in the legacy reader.

Reviews (2) · Last reviewed commit: "Merge branch 'master' into fix/legacy-em..." · Reviewed by Greptile

Comment thread src/lib_json/json_reader.cpp
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 40347616334

Coverage increased (+0.2%) to 90.117%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2746
Covered Lines: 2623
Line Coverage: 95.52%
Relevant Branches: 2657
Covered Branches: 2246
Branch Coverage: 84.53%
Branches in Coverage %: Yes
Coverage Strength: 23786.88 hits per line

💛 - Coveralls

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parse error when "//" comment follows array and array is empty

3 participants