-
Notifications
You must be signed in to change notification settings - Fork 67
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
Make JSON deserializer more robust #2291
Comments
What method are you thinking about? There should not be any As usual, don't forget to check for errors:
|
By the way,
|
Edited my previous comments after I read the doc of |
I had a crash recently: import json::serialization
class A
serialize
var field: Int
end
var des = new JsonDeserializer("garbage")
var a = new A.from_deserializer(des)
print des.errors
print a.field
|
@privat Haa, that was why we didn't use |
What @privat reported is exactly the problem I had, admittedly the instanciation method might not be the most appropriate when dealing with unsafe sources. |
This error could arise when parsing invalid JSON strings (or non-object JSON values) and skipping the call to `deserialize`. See @privat comment in #2291. Pull-Request: #2295 Reviewed-by: Jean Privat <[email protected]> Reviewed-by: Lucas Bajolet <[email protected]>
Was it a single bug? is it fixed by #2295? |
When working on missions, I noticed that the JSON deserializer was a bit too fragile and caused the server to crash multiple times.
When attempting to deserialize malformatted data from client, the deserializer crashes due to some asserts left in the library.
I'd propose to return
nullable
when deserializing, such that when a bad packet is received, the client needs to handle the possibility of a null instead of letting the whole application crash on an assert fail.This does change the API-side a bit though.
@xymus since you are the main developer/maintainer of the library, do you have any idea to make the whole serialization/deserialization more robust while avoiding to burden the clients too much ?
The text was updated successfully, but these errors were encountered: