Add allow_comments: true option for json parser#5428
Merged
Conversation
Since json gem 3.0, JSON.parse will raise an error when the input contains comments unless allow_comments: true is passed. On Ruby head this already shows up as a deprecation warning: warning: Encountered comment in JSON. This will raise an error in json 3.0 unless enabled via `allow_comments: true` Ref. https://github.com/ruby/json/blob/master/CHANGES.md#2026-06-23-2200 Fluentd has accepted comments in JSON so far (embedded JSON in the config parsed by literal_parser, and the json parser plugin), so add allow_comments: true to DEFAULT_JSON_PARSE_OPTIONS to keep that behavior and avoid the future breakage. This constant is shared by both paths, so the single change covers them together. Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
allow_comments: true option for json parser
kenhys
approved these changes
Jul 13, 2026
Watson1978
added a commit
that referenced
this pull request
Jul 13, 2026
…5428) (#5432) **Which issue(s) this PR fixes**: Backport #5428 Fixes # **What this PR does / why we need it**: Related to #5410 Since json gem 3.0, JSON.parse will raise an error when the input contains comments unless `allow_comments: true` is passed. On Ruby head this already shows up as a deprecation warning: ``` warning: Encountered comment in JSON. This will raise an error in json 3.0 unless enabled via `allow_comments: true` ``` Ref. https://github.com/ruby/json/blob/master/CHANGES.md#2026-06-23-2200 Fluentd has accepted comments in JSON so far (embedded JSON in the config parsed by literal_parser, and the json parser plugin), so add `allow_comments: true` to `DEFAULT_JSON_PARSE_OPTIONS` to keep that behavior and avoid the future breakage. Ref. https://github.com/fluent/fluentd/blob/43f46f33efb3e6dda17576568c313b3f758dfa0c/test/config/test_literal_parser.rb#L275-L277 This constant is shared by both paths, so the single change covers them together. **Docs Changes**: **Release Note**: * Add `allow_comments: true` option for json parser Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Shizuo Fujita <fujita@clear-code.com>
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.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
Related to #5410
Since json gem 3.0, JSON.parse will raise an error when the input contains comments unless
allow_comments: trueis passed. On Ruby head this already shows up as a deprecation warning:Ref. https://github.com/ruby/json/blob/master/CHANGES.md#2026-06-23-2200
Fluentd has accepted comments in JSON so far (embedded JSON in the config parsed by literal_parser, and the json parser plugin), so add
allow_comments: truetoDEFAULT_JSON_PARSE_OPTIONSto keep that behavior and avoid the future breakage.Ref.
fluentd/test/config/test_literal_parser.rb
Lines 275 to 277 in 43f46f3
This constant is shared by both paths, so the single change covers them together.
Docs Changes:
Release Note:
allow_comments: trueoption for json parser