-
Notifications
You must be signed in to change notification settings - Fork 68
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(timestamp conversion): use timestamp_nanos_opt
to avoid panics
#979
base: main
Are you sure you want to change the base?
Conversation
timestamp_nanos_opt
to avoid panics
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.
I think this is a breaking change, no? I think the fallibility of these functions needs to be updated. We'll also want to document how to migrate.
Nit: I think we could use clippy to disallow calls to timestamp_nanos()
to avoid accidentally introducing a panic in the future. See https://rust-lang.github.io/rust-clippy/master/#/disallowed_method
@@ -0,0 +1 @@ | |||
Replaced all usages of `timestamp_nanos` with `timestamp_nanos_opt` to avoid panics when the timestamp is out of range. |
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.
Replaced all usages of `timestamp_nanos` with `timestamp_nanos_opt` to avoid panics when the timestamp is out of range. | |
`to_unix_timestamp`, `to_float`, and `uuid_v7` can now return an error if the supplied timestamp is unrepresentable as a nanosecond timestamp. Previously the function calls would panic. |
The changelogs should have the user in mind as the audience. I also think this is a breaking change, no? We'll want to document how to migrate.
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.
Right, marking this PR as a draft for now. I will try to find some propose a migration plan. I need to refresh my memory on the deprecation process as well.
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.
We provide linters for such changes. In this way we have eliminated the deprecation of to_timestamp.
I think there is no problem in this case, because the vector during validation will report that to_unix_timestamp returns an error, and this is not handled
closes: #978