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

fix: Long timestamp default decoding #443

Merged
merged 2 commits into from
Sep 7, 2024

Conversation

redaLaanait
Copy link
Contributor

#368 related

The previous fix made a restriction to prevent accepting int64 as a Go type for the Long-timestamp codec. However, this restriction affected the defaultDecoder when dealing with the JSON-decoded default value represented as int64.

A solution could be:
1 - Improve the default JSON decoding to ensure that the default value is correctly represented as time.Time.
2- Relax the restriction made in the previous fix and limit it to the case of time.Duration.

The PR draft presents these solutions, and a test has been added to cover this case.

@redaLaanait redaLaanait marked this pull request as draft September 6, 2024 17:08
@redaLaanait
Copy link
Contributor Author

Thinking about #368, the fix seems to me overly restrictive and beyond the problem’s scope:

The accidental case of encoding a time.Duration value (which is practically in nano second) as timestamp in milliseconds.

IMHO, that’s a misuse of GO types and not a bug in the library’s implementation of AVRO spec.

@nrwiersma
Copy link
Member

You are likely right that it should be more specific to only restricting the time.Duration case. I will look deeper into this this weekend, when I have more mental bandwidth. Good catch.

@nrwiersma
Copy link
Member

I agree with the approach. This looks like a good fix.

@redaLaanait redaLaanait marked this pull request as ready for review September 7, 2024 11:56
Copy link
Member

@nrwiersma nrwiersma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉 Thanks.

@nrwiersma nrwiersma merged commit 883fb8f into hamba:main Sep 7, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants