Skip to content

Conflict handler not called for conflicts created while offline #5176

Open
@filipesbragio

Description

@filipesbragio

Description

It seems as though amplify in optimistic concurrency mode is not triggering the conflictHandler method when conflicts are created while offline. I have tested on android but not on iOS, although I'd be surprised if this was related to a specific platform.

Categories

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

Steps to Reproduce

In our testing we have a model with a "name" field. That name field can also be edited through a REST endpoint which calls a lambda (or alternatively be modified through AppSync). So our test scenario goes as follows:

The name field starts as "joe".
We go offline in the app and change the field to "mary"
We update the name through our REST endpoint to be "frank"
We go online in the app.

We were expecting the conflictHandler method, in the AmplifyDataStore options, to be called but it isn't. Instead the name is set to "mary" and the version is increased as if the app was simply pushing the changes and ignoring the version the change was made in. Does amplify not store and respect the version in which the changes were made on? Is there a different way of resolving this kind of conflict?

Screenshots

No response

Platforms

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

Flutter Version

12.12.4

Amplify Flutter Version

2.1.0

Deployment Method

Amplify CLI

Schema

I've removed some properties of the schema and only left the relevant property described, "name".

type User
@model
@auth(
    rules: [
        { allow: owner, ownerField: "userId" }
        { allow: private, provider: iam }
    ]
) {
    userId: ID! @primaryKey @auth(
        rules: [
            { allow: groups, groups: ["FORBIDDEN"], operations: [update, delete] }
            { allow: owner, ownerField: "userId", operations: [create, read] }
            { allow: private, provider: iam }
        ]
    )
    name: String!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationImprovements or fixes to public documentation (docs.amplify.aws, pub.dev, readmes).datastoreIssues related to the DataStore Categoryfeature-requestA request for a new feature or an enhancement to an existing API or category.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions