question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integer OverflowException when deserializing an int64 whose value is too large to fit in an int32

See original GitHub issue

Hi,

I have an OpenApi schema whose return types include some Integer type fields that have a format of int64. The Hawaii code generator generates client properties of type int64, but if I try to call the server function and it returns a value which is too large to fit in an int32, then I get this:

image

I had a go at debugging it and I think the error comes from

https://github.com/Zaid-Ajaj/Fable.Remoting/blob/ea1a681100bcfcb02accf81e1fcad6899e7d1a32/Fable.Remoting.Json/FableConverter.fs#L452

where it tries to convert the JSON value into an int, before upcasting to a (u)int64 (and then fails if the value is too large for an int32)?

It actually appears to work ok if the target client property is an Option<int64> rather than a plain int64 (different code paths in the json converter I think?).

Fwiw, I actually fell over this while having a look at making Snowflaqe understand custom ‘Long’ types (ref https://github.com/Zaid-Ajaj/Snowflaqe/issues/8#issuecomment-863949647) and then tried in Hawaii as well (given that int64 is part of the main spec here, where it’s an extension in GraphQl)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Zaid-Ajajcommented, Jul 12, 2021

Should be fixed in v0.29 can you give a try and confirm the fix?

0reactions
Zaid-Ajajcommented, Jul 12, 2021

Yeah I was fixing it while listening to .NET docs in the background xD

Read more comments on GitHub >

github_iconTop Results From Across the Web

Value was either too large or too small for an Int32 [duplicate]
Prefer Int32.TryParse instead of Convert.ToInt32 when the source value is a string. When dealing with values which may potentially overflow - ...
Read more >
Value was either too large or too small for an Int32.
In your case, the numbers are too large to fit into a 32 bit integer (that's what int32 or int are). The result...
Read more >
Value was either too large or too small for an int32
The problem is the integer value in the string can't fit in the 32-bit integer. Int32 (int) can only hold values between -2147483648...
Read more >
Will sometimes fail to query Transmission · Issue #5444
Seems to me that Transmission returns an integer over the maximum size of a 32 bit integer, which Sonarr fails to parse.
Read more >
Migrate from Newtonsoft.Json to System.Text.Json - .NET
Json accepts non-string values, such as a number or the literals true and false , for deserialization to properties of type string.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found