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

Exception for int64 when a field is DateTime #63

Open
jfilby opened this issue Oct 11, 2021 · 3 comments
Open

Exception for int64 when a field is DateTime #63

jfilby opened this issue Oct 11, 2021 · 3 comments

Comments

@jfilby
Copy link

jfilby commented Oct 11, 2021

When I try to unpack an object type that contains int64 types I get:

C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1201) unpack
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(938) unpack_type
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1201) unpack
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1085) unpack_type
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1201) unpack
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1085) unpack_type
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(1201) unpack
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(845) unpack_type
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(842) unpack_int_imp_select
C:\Users\user\.nimble\pkgs\msgpack4nim-0.3.1\msgpack4nim.nim(511) unpack_imp_int64
Error: unhandled exception: int64 [ObjectConversionDefect]

The object I'm packing/unpacking is a seq of an object type. This is to and from a FileStream.

@jangko
Copy link
Owner

jangko commented Oct 12, 2021

can you provide code to reproduce the bug? nim compiler version as well.

@jfilby
Copy link
Author

jfilby commented Oct 12, 2021

I managed to narrow down the issue. It seems that any DateTime field in an object causes the error. I've attached a test case. I understand this isn't something that's handled by MsgPack spec. However the error message is misleading. Is there anyway to fail with a more appropriate error message when a type that isn't compatible is in an object?

fail_msgpack.zip

@jangko
Copy link
Owner

jangko commented Oct 12, 2021

msgpack4nim depends heavily on Nim generics, much of the serialization code generated by the compiler, and that come with a cost. one of them is misleading error message.

a better serialization framework would be using macros + generics to generate better error message.

btw, your problem can be solved by overriding pack_type and unpack_type for DateTime.

@jfilby jfilby changed the title Exception for int64 when unpacking Exception for int64 when a field is DateTime Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants