Skip to content
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

[8.15](backport #40115) x-pack/filebeat/input/http_endpoint: fix handling of deeply nested numeric values #40134

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 8, 2024

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

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-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).

…meric values (#40115)

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 caues 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 represetation is
possible.

Also add an undocumented debug function equivalent to the debug that is
available in the CEL input and improve error logging.

(cherry picked from commit f0401c6)
@mergify mergify bot requested a review from a team as a code owner July 8, 2024 04:10
@mergify mergify bot added the backport label Jul 8, 2024
@mergify mergify bot assigned efd6 Jul 8, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 8, 2024
@botelastic
Copy link

botelastic bot commented Jul 8, 2024

This pull request doesn't have a Team:<team> label.

Copy link
Contributor Author

mergify bot commented Jul 8, 2024

This pull request has not been merged yet. Could you please review and merge it @efd6? 🙏

@efd6 efd6 enabled auto-merge (squash) July 8, 2024 04:12
@efd6 efd6 merged commit 5cbd997 into 8.15 Jul 8, 2024
19 checks passed
@efd6 efd6 deleted the mergify/bp/8.15/pr-40115 branch July 8, 2024 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant