-
Notifications
You must be signed in to change notification settings - Fork 200
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
Amplify API Unathorized error Error #3677
Comments
Hi @dan-codes1 , thanks for opening this issue. We've recently fixed a network-related issue that was causing Authentication problems in the latest version 2.33.3. Thanks! |
Hi, I just updated to the latest version but the bug still persists |
Just to note: Though I gave a specific example using the |
Hi @dan-codes1, thanks for trying out the new Then |
are there any more logs related to the request with verbose log level enabled? |
Hi, The user is signed in. This is the log output for the request:
|
Any updates on this? |
I tried to reproduce this with a very simplified schema of just the User model and I was able to create and update the User, the app user is signed in of course. Could you show us the full schema, including the Listing Model (it is missing in your comment above), or can also provide it to us through |
I used a very simply schema, but kept your auth rules
If you make a mutation request, and put a breakpoint at This is what mine looks like, we are expecting he header Authoriation with token value.
Also if you want to confirm directly with AppSync to narrow out whether there's a bug on the client side or an issue with your backend, you can navigate to the AppSync console and replay your request with a Cognito User Pool user signed in. |
When I create the mutate request, it seems that the final request is being called twice. The first time it uses an api key header and the second time it uses the Authorization header. This is the output: (lldb) po finalRequest (lldb) po finalRequest I ran (lldb) po request This is the type Listing @model @auth(rules: [{allow: public, operations: [read]}, {allow: private, operations: [read]}, {allow: owner, operations: [create, update]}]) { type CheckInItem @model @auth(rules: [{allow: public, operations: [read]}, {allow: private, operations: [read]}, {allow: owner, operations: [create, update]}]) { type CheckOutItem @model @auth(rules: [{allow: public, operations: [read]}, {allow: private, operations: [read]}, {allow: owner, operations: [create, update]}]) { type ListingImage @model @auth(rules: [{allow: public, operations: [read]}, {allow: private, operations: [read]}, {allow: owner, operations: [create, update]}]) { type Booking @model @auth(rules: [{allow: private, operations: [read, update]}, {allow: owner, operations: [create, update]}]) { |
The block of code within
|
Yes, you're right; the request is called only once.
(lldb) po request
|
Just to add a few things:
|
Hi @dan-codes1, thank you for providing more details. I was having troubles getting the schema from your comment. Could you show us the full schema? If you run Could you also confirm in the Amplify CLI project, in I have a hunch that there may be two issues related to why there may be unauthorized responses.
If you can provide the schema file that I can use directly in my sample app (the diagnose report will provide the same), and any more sequences of API calls that you can share. I do see the one you've shared already from the description of this issue:
This is a good example that we'll try and get back to you. In my original repro steps, I only tried creating an updating the User without the full schema containing all the connected models |
Here's a branch you can try out
|
Hello, I have sent the schema via the diagnose command. Report saved: /var/folders/bg/3xhpqh1d6s16yg6wjqqsn3m80000gn/T/cleuviinit/report-1715640147663.zip Yes, I have generateModelsForLazyLoadAndCustomSelectionSet enabled I will try out the bug fix and give feedback. |
Do you have the project identifier? it should be in the log output of the diagnose command. I ran the command and noticed it is different from the value in the path, ie.
We use the project identifier to pull in the project |
Project ID = 334a9b8600e19b2e4377d45122ca8871 |
Hi @dan-codes1, I was able to try out your schema and reproduce to update User issue. Here's a simplification of the schema
Semd
Response
Let's say now I want to remove the value set for
Response
The issue is that I cannot update the user to remove an optional string value, whether it was originally set to something or not. |
The call site on Swift fails because the optional fields are set to Null on update mutations. Because Swift only has a value or On Updates, if the optional field is I opened an issue over in aws-amplify/amplify-category-api#2562 to track this specific issue. A workaround would be to remove the let request = GraphQLRequest<User>.update(user, authMode: .amazonCognitoUserPools)
// Remove values from `request.variables` which have keys but value is `nil`
let updatedUser = try await Amplify.API.mutate(
request: request).get() Regarding lazy loading with the original |
Hello, Just tried this out, it works! Thanks for helping out. Just to be informed, when is there likely to be a fix for this? |
Hi @dan-codes1, please track this issue for library fixes such as #3690 . For updates on the backend functionality issues please check with aws-amplify/amplify-category-api#2562 They may have more details on the status and any data modeling workarounds for your use case. |
I tested the mutations again with an updated owner auth rule to include
I was able to set the optional fields to null. This seems to be the access provided by the given "delete" operation. Would this work for your use cases? Only the owner of the model object that was created is able to delete it, including setting fields to null. |
#3690 has been merged to |
Thanks for the updates! As for the |
Issue fixed and released in version 2.34.0 |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Hi @dan-codes1, please see the latest discussion on If you do not want to add |
Okay I understand the issue. Thank you! @lawmicha |
Describe the bug
I have been experiencing some graphql api bugs since I upgraded my amplify version from 2.26.1 to 2.29.2.
The error occurs when I try to asynchronously load the lazy attibutes in my structs. E.g., take these schemas:
When I try to load the
space
attribute from themessage
, it throws this error:This is the code and api I use:
It throws an error when I try to get the space but not the sender. This only started when I upgraded my amplify project, and started using the new multi auth apis in: #3630
This is the user schema for the
sender
attributeSteps To Reproduce
Expected behavior
To not throw an error and work as it did with the previous apis and version
Amplify Framework Version
2.29.2.
Amplify Categories
API
Dependency manager
Swift PM
Swift version
5.9
CLI version
12.11.1
Xcode version
15
Relevant log output
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
15
Device
iPhone 15
Specific to simulators
no
Additional context
No response
The text was updated successfully, but these errors were encountered: