Closed Gaztoof closed 3 months ago
Upon further investigation, it turns out this bug only happens when I have multiple instances of UserProfile in my DynamoDB, so when I have only one UserProfile, no problem! Everything runs flawless! But as soon as I have more than one, the error starts appearing on all users. But the moment I remove the second UserProfile from the database, the error is gone... Wtf ?
Hi @Gaztoof I'm not an expert on datastore in Amplify JS, but IIRC, the field auth (attached to the owner
field of your models) is not working well within DataStore. This owner
field is only accessible to the actually owner, but when the sync queries are applicable to all signed-in users (this seems aligning to the observation in your last comment). Could you try the following see whether it eliminates the unauthorized error.
owner
field to allow read for all signed-in userowner
field completelyHi @Gaztoof I'm not an expert on datastore in Amplify JS, but IIRC, the field auth (attached to the
owner
field of your models) is not working well within DataStore. Thisowner
field is only accessible to the actually owner, but when the sync queries are applicable to all signed-in users (this seems aligning to the observation in your last comment). Could you try the following see whether it eliminates the unauthorized error.
- Update the auth rule of the
owner
field to allow read for all signed-in user- And if that doesn't work can you try remove the auth rule attached to the
owner
field completely
Thanks a lot! Totally removing every field's @auth fixed the problem! Which unfortunately now leads to security concerns but i'll eventually figure that out...
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
When creating multiple users on my app (using cognito userpools), after a few created users (sometimes 1, sometimes 2 it's random), my app throws the following errors:
And then, i get the error no matter which account I use!!! The first or second or whatever
I've checked on the Cognito console, all accounts belong to the same group, which belongs to a authRole on which i have AdministratorAccess-Amplify and AWSAppSyncAdministrator. So maybe i'm mistaken, but i don't think the problem actually is with my roles / auth. Also, my app is able to Push newly created items, but when i refresh my local data, the app is not aware of the item's existance and it can't sync so it never knows the item exists serverside...
My AWS Console AppSync settings show main auth mode as Cognito, with the proper user group attached.
IMPORTANT TO NOTE, When I go to Console AppSync, then go to Requests, when I call syncUserProfiles or any sync by connecting to the problematic user, the request successfully goes through.
I have looked at the similar issues already, and did every single thing i saw in them, including: "createAPIKey":1 -> amplify push "createAPIKey":0 -> amplify push amplify rebuild api 'amplify update auth' -> 'create or update admin queries API' import using import { DataStore } from '@aws-amplify/datastore'; import using import {DataStore} from 'aws-amplify' (doesn't import properly) Removed node_modules, package_lock, yarn.lock, and run yarn install
I have ran amplify diagnose --send-report With this output: Project Identifier: 02a6e952317032d9500c24b89b51b4c8
Expected behavior
DataStore should be able to sync on every model.
Reproduction steps
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
Mobile Device
Pixel 8
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response