Skip to content

Add allow_comments: true option for json parser#5428

Merged
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:json-parser-option
Jul 13, 2026
Merged

Add allow_comments: true option for json parser#5428
kenhys merged 1 commit into
fluent:masterfrom
Watson1978:json-parser-option

Conversation

@Watson1978

@Watson1978 Watson1978 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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: 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.

"a", // this is a
"b", // this is b
"c" // this is c

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

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>
@Watson1978 Watson1978 added this to the v1.20.0 milestone Jul 13, 2026
@Watson1978 Watson1978 changed the title Add allow_comments: true option for json parser Add allow_comments: true option for json parser Jul 13, 2026
@Watson1978 Watson1978 added the backport to v1.19 We will backport this fix to the LTS branch label Jul 13, 2026
@Watson1978 Watson1978 requested a review from kenhys July 13, 2026 05:01
@kenhys kenhys merged commit fe62566 into fluent:master Jul 13, 2026
42 of 43 checks passed
@Watson1978 Watson1978 added the backported "backport to LTS" is done label 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport to v1.19 We will backport this fix to the LTS branch backported "backport to LTS" is done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants