-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
fix(parsers.json_v2): Properly handle optional fields #14008
Conversation
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.
Thanks for the issue, debug, and PR! It is great to get fixes directly from users.
I will say I am always slightly concerned to make changes to the parsers, given their wide usage, and how users can end up depending on incorrect behavior. However, in this case I do think this new behavior is more correct. I await to see if there is any further fallout.
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.
@caallinson just one request to add a comment... Otherwise the code looks good.
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.
@caallinson thanks for improving this code! Suggestion for extending the code to prevent others to change the error back to nil
for optional entries... What do you think?
@srebhan for review |
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
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.
Thanks for working through this!
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.
Thanks for the amazing work @caallinson!
Co-authored-by: Christian Allinson <christian.allinson@rebuildmanufacturing.com> (cherry picked from commit 69612a8)
Co-authored-by: Christian Allinson <christian.allinson@rebuildmanufacturing.com> (cherry picked from commit 69612a8)
Required for all PRs
resolves #13990
Correct
checkResult()
to return error when result does not exist, even if it is optional (other return value already denotes optional for calling logic).