aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 241 forks source link

Changing model prevents syncing #5143

Open stephenjen opened 1 month ago

stephenjen commented 1 month ago

Description

I recently change the permission of one of my models because for some reason even with the { allow: private, operations: [read] } non-owners were unable to access all the records in the model. Below are the changes:

  #type Friend @model @auth(rules: [{ allow: owner, ownerField: "pOwner"  }{ allow: private, operations: [read] }]) {
  type Friend @model @auth(rules: [{ allow: *private*, ownerField: "pOwner"  }]) {
      id: ID!
      ...
      pOwner: String!
  }

I changed the model by removing the { allow: private, operations: [read] }.

After I made this change and pushed it to the cloud, none of the models would sync after I stopped and started Datastore. It is only when I deleted and reinstalled the app did the app sync'ed properly.

Categories

Steps to Reproduce

  1. Change auth rule for a model
  2. Push change to cloud
  3. Stop and start DataStore, in my case it happens when I log the user out and log in again
  4. Models do not sync

Screenshots

No response

Platforms

Flutter Version

3.16.0

Amplify Flutter Version

1.6.0

Deployment Method

Amplify CLI

Schema

No response

Equartey commented 1 month ago

Hi @stephenjen, sorry you ran into this issue.

We've made several improvements in recent versions of Amplify Flutter, I would recommend updating to a newer version to see if the problem persists.

When you say models do not sync, what is logged? Any errors?

stephenjen commented 1 month ago

No, no errors. Which version would you recommend I update to?

Equartey commented 1 month ago

@stephenjen The latest 2.3.0

stephenjen commented 1 month ago

I've held off on updating because there are several major changes to Datastore in 2.0 that would require changes to my code. Are you fairly certain updating to 2.3.0 would resolve this issue?

Equartey commented 1 month ago

Hi @stephenjen, there's no guarantee that 2.3.0 will solve the problem, but the changes from 1.6.0 to 2.3.0 are quite significant. Primarily, the underlying iOS implementation is now on Amplify Swift V2 and all API calls are routed back through the Amplify Flutter Dart implementation of the API category.

Additionally, the DataStore category specific code changes required to migrate to V2 should be minimal. Please reference our upgrade guide: https://docs.amplify.aws/gen1/flutter/start/project-setup/upgrade-guide/#datastore

stephenjen commented 1 month ago

Thank you for helping me with this. I need to implement push notifications, and I want to be on the latest and greatest for that, so perhaps now is a good time for me to update everything else - amplify, auth, storage, datastore.

I'll update this thread with my findings relating to this issue after the upgrade.

Jordan-Nelson commented 4 weeks ago

Possibly a duplicate of (or at least related to) https://github.com/aws-amplify/amplify-flutter/issues/5184. see: https://github.com/aws-amplify/amplify-flutter/issues/5184#issuecomment-2251262129