-
Notifications
You must be signed in to change notification settings - Fork 72
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(convert): return error when conversion exceeds f64 bounds #1108
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 @dhable, left a couple of comments but this change makes sense to me.
Outside of this PR, I will take a look into the to_float
vs parse_float
implementations for string
arguments.
changelog.d/1107.fix.md
Outdated
@@ -0,0 +1,2 @@ | |||
Fixes the `to_float` function to return an error instead of "infinity" when parsing a string outside |
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.
Replace fix
in the file name with breaking
.
src/compiler/conversion/mod.rs
Outdated
@@ -159,6 +159,11 @@ impl Conversion { | |||
let parsed = s | |||
.parse::<f64>() | |||
.with_context(|_| FloatParseSnafu { s: s.clone() })?; | |||
if parsed.is_infinite() { |
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.
This is quite nuanced, but I think the least surprising behavior is to use https://doc.rust-lang.org/std/primitive.f64.html#method.is_normal here.
Hi @dhable, thank you for this contribution. Do you plan to drive this PR to completion? Let me know if I can help. |
@pront Yes, I just got back from PTO but I'll get the suggestions added. |
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.
Thank you @dhable. Left a couple of suggestions.
Prior to this commit, string values that would exceed the f64 bounds would return `f64::INFINITY`. This leaks a type into the VRL scripts that could cause a panic without support to check for the value. Fixes vectordotdev#1107 Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
Prior to this commit, string values that would exceed the f64 bounds would return
f64::INFINITY
. This leaks a type into the VRL scripts that could cause a panic without support to check for the value.Fixes #1107
Summary
Change Type
Is this a breaking change?
How did you test this PR?
Does this PR include user facing changes?
our guidelines.
Checklist
run
dd-rust-license-tool write
and commit the changes. More details here.References