Skip to content

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.

@redaLaanait redaLaanait force-pushed the fix_timestamp_default_decoding branch from a123069 to cb3d6f5 Compare September 6, 2024 19:09
@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.

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