-
Notifications
You must be signed in to change notification settings - Fork 247
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
DataStore JSON exception on nullable arrays #3575
Comments
Hi @999Rub thanks for sharing this issue and for providing a detailed explanation of what you did! To make sure we tested the same thing, can you please share you graphql schema here as well? |
Hi @fjnoyp , thanks for your reactivity. I've updated my original comment with further details about what it looks like in dart and add a small graphql shcema for a better undertsanding of this issue. |
I have the same problem.
|
Hi @wojciechzahradnikdeviniti does setting an empty array when creating a model with a nullable custom model type array fix this error? I want to make sure you have the same error as listed here. We will investigate a fix for this JSON exception, but are aware that the interim solution is to just initialize with an empty array for now. |
Fixes aws-amplify/amplify-flutter#3575. When a custom type array is not required and `null` is returned from AppSync, deserialization will fail since `getAsJsonArray` will throw for `null` values. This resolves the issue by checking if a field is `null` before attempting deserialization.
Fixes aws-amplify/amplify-flutter#3575. When a custom type array is not required and `null` is returned from AppSync, deserialization will fail since `getAsJsonArray` will throw for `null` values. This resolves the issue by checking if a field is `null` before attempting deserialization.
Thanks - fixed in 1.4.0 |
Closing as this was resolved in v1.4.0 |
Description
This bug report follows my two previous ones #2710 and #3472 .
The previous fixes fixed most of problems using custom type models within a classical model created using Amplify studio or via a custom data schema.
Nonetheless, a small bug is still alive when we use a custom type model as a nullable array.
See this field as exemple:
This field has the following properties:
The custom type model PreOxygenation is only composed of String fields (the issue does not comes from the custom type model itself).
When I try to save a model (and syncing it with the API) it occurs the following error:
It seems this issue comes from the "allow null array" property, caused by the ser/deserialilzation engine wich does not handle null array with custom types.
I've tried the same operation but instead using null for my field
I used an empty array
This small update solved the issue without updating data schema.
This issue is easily counterable but it can waste precious time for future developers wich will face the same bug.
PS: I create this in amplify_flutter because the previous fix was here too and I don't know if the bug only occurs on Android.
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Flutter Version
3.10.0
Amplify Flutter Version
1.3.2
Deployment Method
Amplify CLI
Schema
Classical model exemple:
The notes field is a nullable array using a custom type Note that could be written like this in Dart:
List<Note>?
This is a custom type exemple:
For further details in Dart:
The shcemas exemple gives this:
User user = User(id: id, patientID: patientID, name: name, notes: null)
OR
User user = User(id: id, patientID: patientID, name: name)
(without using notes fields because it is nullable)Trying to save this will trigger the issue.
Now turn into this:
User user = User(id: id, patientID: patientID, name: name, notes: [] )
This will works fine.
The text was updated successfully, but these errors were encountered: