[8.15](backport #40115) x-pack/filebeat/input/http_endpoint: fix handling of deeply nested numeric values #40134
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.
Proposed commit message
In order to avoid precision loss during processing of numeric values that cannot be exactly represented in a double-precision floating point value, the json.Number unmarshaller is used. This has the effect that conversion to native types on exit from the CEL program fails since protobuf does not handle json.Number. For non-nested values that are referenced by the CEL runtime, this does not cause an issue since the native-to-value conversion will attempt to convert the string representation of the numeric value. This conversion is not recursively applied.
Recursively apply the type conversion to all child values on referencing a value; converting numeric values to the most exact type and falling back to a string representation if no native numeric representation is possible.
Also add an undocumented debug function equivalent to the debug that is available in the CEL input.
Note that an alternative would be to always convert
json.Number
to string. I'm happy with that approach as well.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs
This is an automatic backport of pull request #40115 done by [Mergify](https://mergify.com).