-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure parser returns hash #4474
Merged
Merged
Conversation
This file contains 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
daipom
force-pushed
the
make-sure-parser-returns-hash
branch
3 times, most recently
from
April 30, 2024 02:05
900854d
to
85e20ad
Compare
It is wrong for Parser to return a record that is not Hash. Subsequent processing may result in errors. Signed-off-by: Daijiro Fukuda <[email protected]>
It is wrong for Parser to return a record that is not Hash. Subsequent processing may result in errors. Signed-off-by: Daijiro Fukuda <[email protected]>
in_http didn't support yield of Parser. The specification assumed that Parser could return Array. However, this is wrong. Parser shouldn't return Array. Signed-off-by: Daijiro Fukuda <[email protected]>
Config to reproduce: <source> @type sample tag test.array sample {"message": "[{\"k\":\"v\"}, {\"k2\":\"v2\"}]"} </source> <filter test.**> @type parser key_name message <parse> @type json </parse> </filter> <match test.**> @type stdout </match> Result: 2023-03-21 23:24:52.004470792 +0900 test.array: {"k":"v"} 2023-03-21 23:24:52.004470792 +0900 test.array: {"k":"v"} ... Signed-off-by: Daijiro Fukuda <[email protected]>
daipom
force-pushed
the
make-sure-parser-returns-hash
branch
from
April 30, 2024 02:06
85e20ad
to
6cace97
Compare
ashie
reviewed
Apr 30, 2024
ashie
approved these changes
Apr 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! I have added |
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:
Hash
#4100parser_msgpack
and some refactoringWhat this PR does / why we need it:
parser_json
andparser_msgpack
return Hash.parser_json
andparser_msgpack
accept onlyHash
orArray
ofHash
It is wrong for Parser to return a record that is not Hash.
Subsequent processing may result in errors.
parser_json
andparser_msgpack
could return non-Hash objects, so they have been fixed in this PR.In addition,
in_http
was designed based on this wrong behavior, so it has been fixed as well in this PR.However, we have a remaining problem with
filter_parser
.filter_parser
could return Array based on this wrong behavior.This PR disables it, so it can not return multiple parsed results anymore.
Even though it was wrong to begin with, it's possible that this change in specifications would be unacceptable.
We need to consider this change carefully.
I explain some examples in detail below.
Docs Changes:
TODO
Release Note:
parser_json
andparser_msgpack
return Hash.parser_json
andparser_msgpack
accept onlyHash
orArray
ofHash
Example: parser_json
Case: No subsequent processing (without
convert_values
)Config
Operation
Result BEFORE this fix
Result AFTER this fix
Case: No subsequent processing (with
convert_values
)Config
Operation
Result BEFORE this fix
Result AFTER this fix
Case: With subsequent filter processing
Config
Operation
Result BEFORE this fix
Result AFTER this fix
Example: filter_parser
Case: No subsequent processing (without any option)
Config
Result BEFORE this fix
Result AFTER this fix
Case: No subsequent processing (with some options such as
reserve_data
)parse failed no implicit conversion of Array into Hash
Config
Result BEFORE this fix
Result AFTER this fix
Case: With subsequent filter processing
Config
Result BEFORE this fix
Result AFTER this fix