Skip to content
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 cloud sync JsonSyntaxException #3472

Closed
4 of 14 tasks
999Rub opened this issue Jul 26, 2023 · 5 comments · Fixed by aws-amplify/amplify-android#2545
Closed
4 of 14 tasks

DataStore cloud sync JsonSyntaxException #3472

999Rub opened this issue Jul 26, 2023 · 5 comments · Fixed by aws-amplify/amplify-android#2545
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed.

Comments

@999Rub
Copy link

999Rub commented Jul 26, 2023

Description

This issue follows a previous one (#2710 ) .

A previous fix has been released (https://github.com/aws-amplify/amplify-flutter/releases/tag/v0.6.14) but a new exception appears.
The context is the same, I use a Models where fields are basics type (String, Int, etc..) provided by Amplify Studio, but, there are also "Custom Types", wich are simply classical models without default ID and relationnal options.

This is a snippet of one of my classical models:
image

As you can see, there is a "Custom Type" field called "Weight" wich is the following:

image

From there, before the (https://github.com/aws-amplify/amplify-flutter/releases/tag/v0.6.14) fix (that is also availbale in the latest amplify flutter version 1.2.1 #2710 (comment) ), the issue was that when I saved a Model wich contains custom type offline, and then syncing it online, it wasn't working.

Now, when I save a Model wich contains a custom type, independamently of online or offline save, it's not working at all and throw this exception:

I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
3
E/gralloc4( 3248): Empty SMPTE 2094-40 data
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
I/amplify:flutter:datastore( 3248): Saved item: SerializedModel{id='123', serializedData={allergies=, birthday=2021-06-01 00:00:00.000 , weight=[SerializedCustomType{serializedData={date=2023-07-26 09:31:35.907895, weight=4.0}, customTypeName=CustomTypeSchema{name='Weight', pluralName='Weights', fields={date=CustomTypeField{name='date', javaClassForValue='class java.lang.String', targetType='String', isRequired=true, isArray=false, isEnum=false, isCustomType=false}, weight=CustomTypeField{name='weight', javaClassForValue='class java.lang.Double', targetType='Double', isRequired=true, isArray=false, isEnum=false, isCustomType=false}}}}], name=tevyv}, modelName=Animal}
E/gralloc4( 3248): Empty SMPTE 2094-40 data
W/System.err( 3248): SLF4J: No SLF4J providers were found.
W/System.err( 3248): SLF4J: Defaulting to no-operation (NOP) logger implementation
W/System.err( 3248): SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
E/gralloc4( 3248): Empty SMPTE 2094-40 data
I/amplify:aws-datastore( 3248): Successfully enqueued PendingMutation{mutatedItem=SerializedModel{id=123', serializedData={ birthday=2021-06-01 00:00:00.000, weight=[SerializedCustomType{serializedData={date=2023-07-26 09:31:35.907895, weight=4.0}, customTypeName=CustomTypeSchema{name='Weight', pluralName='Weights', fields={date=CustomTypeField{name='date', javaClassForValue='class java.lang.String', targetType='String', isRequired=true, isArray=false, isEnum=false, isCustomType=false}, weight=CustomTypeField{name='weight', javaClassForValue='class java.lang.Double', targetType='Double', isRequired=true, isArray=false, isEnum=false, isCustomType=false}}}}], name=tevyv}, modelName=Animal}, mutationType=CREATE, mutationId=73af14c6-2b86-11ee-94ad-f1325bdf7330, predicate=MatchAllQueryPredicate}
E/amplify:aws-datastore( 3248): Error ended observation of mutation outbox:
E/amplify:aws-datastore( 3248): com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: []
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:1003)
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:1062)
E/amplify:aws-datastore( 3248): at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:163)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.appsync.SerializedModelAdapter.deserialize(SerializedModelAdapter.java:115)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.appsync.SerializedModelAdapter.deserialize(SerializedModelAdapter.java:43)
E/amplify:aws-datastore( 3248): at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
E/amplify:aws-datastore( 3248): at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:130)
E/amplify:aws-datastore( 3248): at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:991)
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:956)
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:905)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.syncengine.GsonPendingMutationConverter.fromRecord(GsonPendingMutationConverter.java:72)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.syncengine.PersistentMutationOutbox.lambda$load$15$com-amplifyframework-datastore-syncengine-PersistentMutationOutbox(PersistentMutationOutbox.java:260)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.syncengine.PersistentMutationOutbox$$ExternalSyntheticLambda16.accept(Unknown Source:6)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter.lambda$query$4$com-amplifyframework-datastore-storage-sqlite-SQLiteStorageAdapter(SQLiteStorageAdapter.java:406)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.storage.sqlite.SQLiteStorageAdapter$$ExternalSyntheticLambda0.run(Unknown Source:10)
E/amplify:aws-datastore( 3248): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
E/amplify:aws-datastore( 3248): at java.util.concurrent.FutureTask.run(FutureTask.java:264)
E/amplify:aws-datastore( 3248): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/amplify:aws-datastore( 3248): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/amplify:aws-datastore( 3248): at java.lang.Thread.run(Thread.java:1012)

E/amplify:aws-datastore( 3248): Caused by: java.lang.IllegalStateException: Not a JSON Object: []
E/amplify:aws-datastore( 3248): at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:91)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.appsync.SerializedCustomTypeAdapter.deserialize(SerializedCustomTypeAdapter.java:80)
E/amplify:aws-datastore( 3248): at com.amplifyframework.datastore.appsync.SerializedCustomTypeAdapter.deserialize(SerializedCustomTypeAdapter.java:41)
E/amplify:aws-datastore( 3248): at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
E/amplify:aws-datastore( 3248): at com.google.gson.Gson.fromJson(Gson.java:991)
E/amplify:aws-datastore( 3248): ... 20 more
129
E/gralloc4( 3248): Empty SMPTE 2094-40 data

I don't know if it is related, but at the application launch, datastore print the same message mulitple times:

I/amplify:aws-datastore( 3248): Orchestrator lock released.
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
W/m.manitty.vetmo( 3248): Long monitor contention with owner pool-5-thread-1 (3484) at void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action)(SubscriptionEndpoint.java:196) waiters=0 in void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action) for 2.885s
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
I/amplify:aws-datastore( 3248): Orchestrator lock acquired.
I/amplify:aws-datastore( 3248): DataStore plugin initialized.
I/amplify:aws-datastore( 3248): Orchestrator lock released.
2
E/gralloc4( 3248): Empty SMPTE 2094-40 data
W/m.manitty.vetmo( 3248): Long monitor contention with owner pool-5-thread-1 (3484) at void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action)(SubscriptionEndpoint.java:196) waiters=1 in void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action) for 3.057s
2
E/gralloc4( 3248): Empty SMPTE 2094-40 data
W/m.manitty.vetmo( 3248): Long monitor contention with owner pool-5-thread-1 (3484) at void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action)(SubscriptionEndpoint.java:196) waiters=3 in void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action) for 1.621s
W/m.manitty.vetmo( 3248): Long monitor contention with owner pool-5-thread-1 (3484) at void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action)(SubscriptionEndpoint.java:196) waiters=2 in void com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(com.amplifyframework.api.graphql.GraphQLRequest, com.amplifyframework.api.aws.AuthorizationType, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Consumer, com.amplifyframework.core.Action) for 1.771s

I might change my custom type for classic models because it occurs too much issues with Datastore & Appsync within a Flutter app atm.

PS: I mark IOS & Android as Platform because I use Flutter, but I work on a Android device so I don't know if the same issue occurs on IOS devices AND I use the amplify_datastore ^1.2.0-supports-only-mobile+1

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Create a classic Model in Amplify studio
  2. add classic fields
  3. add a "Custom Type" field
  4. within the "Custom Type" field add classic fields (provided by amplify studio)
  5. In the Flutter app, crate a new model
  6. Then try to sync it to the cloud

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.10.0

Amplify Flutter Version

1.2.1

Deployment Method

Amplify CLI

Schema

type Animal @model @auth(rules: [{allow: owner}]) {
  id: ID!
  birthday: String!
  name: String!
  weight: [Weight!]!
}

type Weight {
  weight: Float!
  date: String!
}
@dnys1 dnys1 added datastore Issues related to the DataStore Category pending-triage This issue is in the backlog of issues to triage labels Jul 26, 2023
@jamontesg
Copy link

Same error for me.

Android version 12
Flutter (Channel stable, 3.10.6

amplify_datastore: ^1.3.0
amplify_datastore_plugin_interface: ^1.3.0

my schema has custom fields

{
id: ID!
tag: String
letag: String
eid: String
events: [Event]
images: [S3Object]
documents: [S3Object]
}

and gets this error on create new item operation:

E/amplify:aws-datastore(27314): Error ended observation of mutation outbox:
E/amplify:aws-datastore(27314): com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: []

This operation worked with the mobile+0 development version

@dnys1 dnys1 added bug Something is not working; the issue has reproducible steps and has been reproduced requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed. and removed pending-triage This issue is in the backlog of issues to triage labels Jul 28, 2023
@dnys1
Copy link
Contributor

dnys1 commented Jul 28, 2023

Thank you for the feedback, @jamontesg. We are currently investigating this issue and believe there is a bug in the Android library.

I will keep this ticket updated as we learn more.

dnys1 pushed a commit to aws-amplify/amplify-android that referenced this issue Aug 3, 2023
Fixes: aws-amplify/amplify-flutter#3472, aws-amplify/amplify-flutter#3482

The issue of ser/deseralizing custom types was partially fixed by #2350. However, once this was released, customers quickly noticed new issues. The prior fix did not handle arrays of custom types which this PR addresses.
dnys1 pushed a commit to aws-amplify/amplify-android that referenced this issue Aug 3, 2023
Fixes: aws-amplify/amplify-flutter#3472, aws-amplify/amplify-flutter#3482

The issue of ser/deseralizing custom types was partially fixed by #2350. However, once this was released, customers quickly noticed new issues. The prior fix did not handle arrays of custom types which this PR addresses.
@dnys1 dnys1 reopened this Aug 8, 2023
@dnys1
Copy link
Contributor

dnys1 commented Aug 8, 2023

A fix for this has been merged in the Amplify Android repo: aws-amplify/amplify-android#2545

We will get this fix released as soon as possible.

@jamontesg
Copy link

jamontesg commented Aug 14, 2023

Any date for this release?

@dnys1
Copy link
Contributor

dnys1 commented Aug 15, 2023

The fix for this has been released in v1.3.2. Thank you for your patience resolving this and please let us know if you continue to face issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category requires-android-fix This issue is the result of an underlying Amplify Android issue that needs to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants