-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(@aws-amplify/datastore): handle sync query unauthorized #7926
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Fixes a bug where the sync engine breaks when a sync query returns an
unauthorized
error.The expected behavior for DataStore is that an unauthorized error on a model should not break syncing for other models.
Currently, when a sync query request returns unauthorized, we get the following unhandled error
on this line.
An unauthorized query response typically won't return any
items
, so this PR adds a check to see ifitems
are defined before attempting to iterate over them. If not defined, we return an empty list (items: []
) andnextToken: null
to signal to theretrievePage
method that it shouldn't attempt to retrieve additional pages via this query.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.