Closed osehmathias closed 5 days ago
At first I thought this was related to updating records where there is a belongsTo / hasMany relationship.
However, this is occurring on all updates of data in DataStore
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Successfully saved model: FlutterSerializedModel(values: ["enteredAt": Amplify.JSONValue.string("2023-12-19T10:49:21.711000000Z"), "updatedBy": Amplify.JSONValue.string("7b56400c-b895-448a-bda3-e86fb829bd0e"), "__typename": Amplify.JSONValue.string("Record"), "editing": Amplify.JSONValue.boolean(true), "createdBy": Amplify.JSONValue.string("7b56400c-b895-448a-bda3-e86fb829bd0e"), "updatedAt": Amplify.JSONValue.string("2023-12-19T10:49:21.743000000Z"), "userInputs": Amplify.JSONValue.object(["associatedField": Amplify.JSONValue.string("record"), "elements": Amplify.JSONValue.array([]), "associatedId": Amplify.JSONValue.string("5cdf707f-6025-4cf2-81c6-b230387bbd6f")]), "id": Amplify.JSONValue.string("5cdf707f-6025-4cf2-81c6-b230387bbd6f"), "clientID": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "draft": Amplify.JSONValue.boolean(false), "createdAt": Amplify.JSONValue.string("2023-12-19T10:49:21.743000000Z"), "owner": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3::a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "entryID": Amplify.JSONValue.string("f2f78cca-c7d9-407d-8df8-885c1f411761"), "sectionID": Amplify.JSONValue.string("c959d374-1e56-49f7-9bae-888fda62d076")], _modelName: "Record")
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Successfully saved model: FlutterSerializedModel(values: ["createdBy": Amplify.JSONValue.null, "createdAt": Amplify.JSONValue.string("2023-12-19T06:39:38.075000000Z"), "logic": Amplify.JSONValue.null, "addLogic": Amplify.JSONValue.null, "owner": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "order": Amplify.JSONValue.number(10.0), "icon": Amplify.JSONValue.string("LocalDining"), "id": Amplify.JSONValue.string("f2f78cca-c7d9-407d-8df8-885c1f411761"), "updatedAt": Amplify.JSONValue.string("2023-12-23T11:20:31.322000000Z"), "analytics": Amplify.JSONValue.null, "name": Amplify.JSONValue.string("Dinner"), "count": Amplify.JSONValue.number(1.0), "draftRecordID": Amplify.JSONValue.string(""), "entrySections": Amplify.JSONValue.object(["associatedId": Amplify.JSONValue.string("f2f78cca-c7d9-407d-8df8-885c1f411761"), "associatedField": Amplify.JSONValue.string("entryEntrySectionsId"), "elements": Amplify.JSONValue.array([])]), "settings": Amplify.JSONValue.null, "section": Amplify.JSONValue.object(["updatedAt": Amplify.JSONValue.string("2023-12-19T06:39:38.075Z"), "createdBy": Amplify.JSONValue.null, "settings": Amplify.JSONValue.string("{\"hasChart\":true}"), "order": Amplify.JSONValue.number(10.0), "complete": Amplify.JSONValue.null, "createdAt": Amplify.JSONValue.string("2023-12-19T06:39:38.075Z"), "name": Amplify.JSONValue.string("Daily Measurements"), "owner": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "entries": Amplify.JSONValue.object(["associatedId": Amplify.JSONValue.string("c959d374-1e56-49f7-9bae-888fda62d076"), "associatedField": Amplify.JSONValue.string("section"), "elements": Amplify.JSONValue.array([])]), "id": Amplify.JSONValue.string("c959d374-1e56-49f7-9bae-888fda62d076"), "clientID": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3")]), "complete": Amplify.JSONValue.null, "type": Amplify.JSONValue.null, "__typename": Amplify.JSONValue.string("Entry"), "clientID": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3")], _modelName: "Entry")
Failed to parse the event DataStoreError: No decoder found for model named MutationEvent
Recovery suggestion: There is no decoder registered for the model named MutationEvent. Register models with `ModelRegistry.register(modelName:)` at startup.
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Failed to parse the event DataStoreError: No decoder found for model named MutationEvent
Recovery suggestion: There is no decoder registered for the model named MutationEvent. Register models with `ModelRegistry.register(modelName:)` at startup.
Thanks @osehmathias. Is this causing exceptions at the Dart layer or silent exceptions in iOS logs?
@osehmathias does creating a new model without the @auth rule in your schema fix this issue?
Could you share the schema of the simplest model your are using that triggers this error? For example, does a simple model trigger this exception as well?
type SimpleModel @model {
id: ID!
indexId: ID! @index(name: "byIndexId")
content: String!
}
@haverchuck - Thanks for the reply. They are silent exceptions in the iOS logs in Xcode. It occurs on every 'save' operation. I have tried to log out / log in, clear the datastore and sync again.
@fjnoyp - I created a simple model very similar to your example:
type SimpleModel
@model {
id: ID!
clientID: ID @index(name: "byClientID")
content: String
}
It does indeed continue to occur.
This is the save for reference:
SimpleModel model = SimpleModel(clientID: clientId, content: 'Test');
await Amplify.DataStore.save(model);
This is the error:
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Successfully saved model: FlutterSerializedModel(values: ["createdAt": Amplify.JSONValue.null, "__typename": Amplify.JSONValue.string("SimpleModel"), "updatedAt": Amplify.JSONValue.null, "content": Amplify.JSONValue.string("Test"), "clientID": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "id": Amplify.JSONValue.string("fce15101-948f-475f-8f12-23ade79c1f9d")], _modelName: "SimpleModel")
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Failed to parse the event DataStoreError: No decoder found for model named MutationEvent
Recovery suggestion: There is no decoder registered for the model named MutationEvent. Register models with `ModelRegistry.register(modelName:)` at startup.
Hi @osehmathias thanks for sharing. It appears there's an issue with your createdAt
and updatedAt
fields being null and causing an issue with JSON serialization. Those fields should be set automatically but for some reason are not set in your case.
Are you on the latest version of Amplify Flutter (1.6.2) and Amplify CLI? Can you try doing a pub clean/get and also regenerating and pushing your models again via Amplify CLI?
Thanks @fjnoyp
To test this, I defined the createdAt
and updatedAt
fields in the schema so they would be available to set as part of the query.
type SimpleModel @model {
id: ID
clientID: ID @index
content: String
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
I ran flutter clean
, although the latest version of Amplify Flutter is (1.6.1) as reported by pub.
I ran flutter pub get
, followed by amplify codegen models
The error persists.
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Encoder Foundation.(unknown context at $196c8ec20).__JSONEncoder
Successfully saved model: FlutterSerializedModel(values: ["id": Amplify.JSONValue.string("711bd285-cf04-4e0e-ae9d-5284ef82f4f3"), "__typename": Amplify.JSONValue.string("SimpleModel"), "createdAt": Amplify.JSONValue.string("2023-12-28T22:20:55.372693000Z"), "clientID": Amplify.JSONValue.string("a5ca2f8e-747c-4919-ae91-951fc1c85cf3"), "updatedAt": Amplify.JSONValue.string("2023-12-28T22:20:55.372781000Z"), "content": Amplify.JSONValue.string("This")], _modelName: "SimpleModel")
Failed to parse the event DataStoreError: No decoder found for model named MutationEvent
Recovery suggestion: There is no decoder registered for the model named MutationEvent. Register models with `ModelRegistry.register(modelName:)` at startup.
I should add that data appears to be getting saved, and this error, which only appears in Xcode, doesn't appear to interfere with running the app. However, as I am sure you can relate, it is pleasing to have no errors in the console.
Hey @osehmathias can you please remove those fields? They are created and populated automatically within Amplify so creating them again can break the serialization step.
I will get back to you in a few days when I have tested further on fresh testing apps.
Hello @osehmathias - I believe these logs can be ignored. I do agree that the logs should be removed though. I will mark this as a bug. If you believe that there are issues impacting your application related to these logs, please let us know.
@Jordan-Nelson - thanks for following up. The bug is not impeding development or use of the product, so it has taken me a while to come back to it.
I was not able to reproduce this error on a minimal new build e.g. from the AWS Tutorial for Flutter. However, when I create a flutter app and integrate one of my existing backends, I still get it.
The flutter app I reported from originally uses an existing backend that is complex in its nature - enums, custom types, multiple auth rules, and so forth. It is not obvious where the problem originates.
I will post back in the thread if I find something or if this starts blocking function.
@osehmathias Apologies for the delay. Thank you for that info.
Did anyone has find any solution for this problem? I am using OIDC auth strategy and facing this same issue.
@workoholicgeek sorry that you are facing this issue. Do you work with @osehmathias on the same project? if not would you please open a new issue and fill out the issue template so that we will have the information to investigate it further. Thanks.
Same issue here. Different project. Only happens on iOS.
@Haapavuo a fix for this was already released. I'm going to close this issue as the original issue was fixed.
Please upgrade to the latest of Amplify DataStore and verify the error is gone.
If you are on the latest and still seeing this issue, please open a new issue so we can gather enough information to reproduce.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Description
When saving an item with datastore, as well as on startup, I get this error about a decoded not being found.
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Flutter Version
3.16.5
Amplify Flutter Version
1.6.0
Deployment Method
Amplify CLI
Schema