Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I recently stubble upon a crash when creating a SQLite schema model with an Array type member like so:
if I submit a JSON with an empty array, I got a crash back here.
So I update my Fluent* libs to the last rc4 version and investigate for this bug.
The reason of the crash is that when the
_UnkeyedEncodingContainer
get an empty array, none of its methods get called and as a consequence, no data is returned to the encoder and it doesn't throw any_DoJSONError()
either.I'm not sure this is the right way to fix this, but after adding some test to check the encoding/decoding of an empty and non empty array, I've added a
guard let
statement on theencoder.data
value and throw the_DoJSONError
in case it'snil
But maybe it would be better to move the fix directly inside the
_UnkeyedEncodingContainer
to be sure we are dealing with an array but I didn't find a clean solution at this location.To reproduce the bug from a real vapor project, run this sample project:
bugEmptyArray.zip
Then run this cUrl command:
And you should got the crash with the last SQLite release.
Hope it will help!
Have a great day!