-
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: Enhance the "unauthorized" error message with recovery instructions #12652
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.
We might want to consider a more generalized "error mapper" like we have in DataStore.
Either way, please take a look at it: https://github.com/aws-amplify/amplify-js/blob/main/packages/datastore/src/sync/processors/errorMaps.ts
We also need to make sure remapping these errors doesn't break customers (like ourselves/DataStore) who might be relying on particular error messages. E.g., will this interfere with DataStore multi-auth? (This is the main reason I'm asking for a look at the mapper regardless of whether you want to so something similar.)
I'm not opposed to an error mapper and if something like this existed, I would have used it here. Since this change is localized to this one use-case, I think an error mapper might make a good refactoring as we bring in a second error remapping use-case, right? |
…mplify-js into 01-api-unauth-message
We've had a discussion about keeping the error message consistent with what came before. Currently these 401's are coming through with the message |
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.
Couple nits, q's.
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.
The error formation part looks good to me.
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.
With the exception of what Jon pointed out previously, LGTM!
b743ad1
Description of changes
For all
graphql
calls made through thegenerateClient
interface. When a permission error is returned, this change remaps the error with a clearer error message:Description of how you validated changes
Tested manually in sample app and by updating unit tests to cover both the call and subscription usecases.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.