Skip to content

Backport(v1.19): Add allow_comments: true option for json parser (#5428) - #5432

Merged
Watson1978 merged 1 commit into
v1.19from
backport-to-v1.19/pr5428
Jul 13, 2026
Merged

Backport(v1.19): Add allow_comments: true option for json parser (#5428)#5432
Watson1978 merged 1 commit into
v1.19from
backport-to-v1.19/pr5428

Conversation

@github-actions

Copy link
Copy Markdown

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.

"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

**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.
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>
@Watson1978 Watson1978 added this to the v1.19.4 milestone Jul 13, 2026
@Watson1978
Watson1978 merged commit 37735b3 into v1.19 Jul 13, 2026
18 checks passed
@Watson1978
Watson1978 deleted the backport-to-v1.19/pr5428 branch July 13, 2026 07:06
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.

1 participant