I’m encountering an issue with AWS Amplify DataStore in my Android application. When I remove the { allow: public, operations: [read, create] }
authorization rule from my User
model, I receive the following error during the initial sync:
API sync failed – transitioning to LOCAL_ONLY.
W/amplify:aws-datastore(20148): DataStoreException{message=Initial sync during DataStore initialization failed., cause=java.lang.RuntimeException: IrRecoverableException{message=Empty response from AppSync., cause=null, recoverySuggestion=Report to AWS team.}, recoverySuggestion=There is a possibility that there is a bug if this error persists. Please take a look at
W/amplify:aws-datastore(20148): https://github.com/aws-amplify/amplify-android/issues to see if there are any existing issues that
W/amplify:aws-datastore(20148): match your scenario, and file an issue with the details of the bug if there isn’t.}
### `User` Model Schema:
```graphql
type User @model
@auth(rules: [
{ allow: owner, ownerField: "userID", operations: [read, create, update, delete] }
]) {
id: ID!
userID: String!
deletedAt: AWSDateTime
firstName: String!
lastName: String!
birthday: AWSDate!
phone: AWSPhone!
}
Steps Taken:
- Initially, my
User
model included the following auth rule:{ allow: public, operations: [read, create] }
, and everything worked fine. - I removed the
{ allow: public, operations: [read, create] }
rule to restrict access only to the owner. - Upon removing this rule, the initial sync fails with the above error.
Question:
- Why does the initial sync fail when I remove the
{ allow: public, operations: [read, create] }
rule from myUser
model? - How can I restrict access to only the owner while ensuring the initial sync succeeds?
I’ve checked the AWS documentation and GitHub issues but couldn’t find a solution that resolves this specific problem. Any insights or suggestions would be greatly appreciated!
Kronio Backend is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.