openstacknetsdk / openstack.net

An OpenStack Cloud SDK for Microsoft .NET
http://www.openstacknetsdk.org
Other
117 stars 101 forks source link

json parse exception while reading image list #620

Closed bblrlo closed 7 years ago

bblrlo commented 8 years ago

Exception occurs if image size in bytes larger that int32 max value Exception: Newtonsoft.Json.JsonReaderException: JSON integer 8589934592 is too large or small for an Int32. Path 'images[0].OS-EXT-IMG-SIZE:size', line 1, position 571. at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)

Json response: {"images": [{"status": "ACTIVE", "updated": "2016-06-08T15:28:20Z", "links": [{"href": "", "rel": "self"}, {"href": "", "rel": "bookmark"}, {"href": "", "type": "application/vnd.openstack.image", "rel": "alternate"}], "id": "1ecde54f-fcb7-4588-b728-e58a52bca93a", "OS-EXT-IMG-SIZE:size": 8589934592, "name": "COS", "created": "2016-06-08T15:27:44Z", "minDisk": 10, "progress": 100, "minRam": 256, "metadata": {"architecture": "x86_64"}}, {"status": "ACTIVE", "updated": "2016-06-08T12:20:11Z", "links": [{"href": "", "rel": "self"}, {"href": "", "rel": "bookmark"}, {"href": "", "type": "application/vnd.openstack.image", "rel": "alternate"}], "id": "0d8d7092-004c-4650-aab7-f39057df174e", "OS-EXT-IMG-SIZE:size": 283979999, "name": "CentOS-6-x86_64-GenericCloud-20141129_01", "created": "2016-06-08T08:13:52Z", "minDisk": 20, "progress": 100, "minRam": 1024, "metadata": {"murano_image_info": "{\"type\": \"linux\", \"title\": \"CentOS\"}", "description": null}}]}

code that throw exception

try{ var res = cs.ListImagesAsync(); res.Wait(10000); foreach (Image i in res.Result){ Console.WriteLine(i.Name,": ",i.Id); } }catch(Exception e1){ Console.WriteLine(e1.InnerException); }

paulkats commented 7 years ago

I just changed Size property in Image class to be Int64

ghost commented 7 years ago

@carolynvs is the hotfix branch available in nuget (hit this Image serialization bug). I might just be dull, but I didn't spot it and before pulling down the branch and building I figured I would check.

carolynvs commented 7 years ago

@jrackliffe Derp, sorry about that I merged and forgot to release it to Nuget. Here it is: https://www.nuget.org/packages/openstack.net/1.7.7

ghost commented 7 years ago

Awesome! Just getting my hands dirty the last couple days and tripping over a couple things like this and the network endpoint. Cloned the dev branch and was back in action, but would rather source from nuget any day of the week. I wasn't sure if I was just missing the obvious. Appreciate the help and depending on if I can get my sea legs and legal to give me the all clear I hopefully will try and throw some time at the backlog.