-
Notifications
You must be signed in to change notification settings - Fork 315
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
Unexpected UTCTime [de]serialization behaviour #500
Comments
but you construct invalid Valid options:
I'm not sure which variant is the best one |
I think the current behaviour is quite reasonable. It doesn't prevent someone from deliberately constructing and serializing a bogus |
An invalid UTCTime could be constructed indeliberately (by mistake) as well, in fact that's how I've found it: by parsing it from a format, composition of which turned out to be buggy (while I've assumed that it's not). That was a bug, and now I'm doing basic validation (akin to that in aeson), but was surprising to find it as a deserialization error. Not a big deal though, just writing to explain it better. |
I guess the reasoning is that in Haskell we don't program defensively, as type-safety should guarantee most things. If some other library violated invariant, it's that library problem. it's not That's said, there is @defanor do you want to open issue / make PR to |
OOC, why doesn't aeson reuse time's own functions for formatting and parsing? Though neither does it hold in |
because we parse |
Here is an example:
Though the time is indeed invalid in this case, I'd expect
decode (encode a) == a
to hold. It's rather unfortunate when trying to deserialize aeson-generated JSON with aeson, but even if it is for compatibility with other libraries/languages, perhaps serialization shouldn't produce the values that are considered invalid (even though that may lead to information loss). In any case, it's not quite an expected behaviour: input requirements are more strict than output ones.The text was updated successfully, but these errors were encountered: