Back

Appwrite is showing wrong error.

  • 0
  • Databases
  • Web
debashish
7 Oct, 2023, 10:02

When I try to create a document with a ID which is already present . it throws wrong error saying "The current user is not authorized to perform the requested action." it should actually show. " Document with the requested ID already exists. Try again with a different ID or use "unique()" to generate a unique ID."

NOTE:

  1. Role is "any" for all collection. so no issue with authorization.
  2. Authroization error doesn't show up on first time creation of nested object.
  3. Above is only happening for relationship (nested document) not the direction collection documents.

const testDataSave = async () => { await databases.createDocument(DATABASE_ID, "users_id", "random_doc_id", { basicDetails: { $id: "random_doc_id", name: "randome name", age: 31 }, }); };

TL;DR
The user is experiencing a problem with Appwrite displaying the wrong error message. When trying to create a document with an ID that already exists, instead of showing the correct error message about the ID already existing, it displays an authorization error. The user has confirmed that the role is set to "any" for all collections so authorization is not the issue. The problem only occurs when creating nested documents, not with regular collection documents. A suggested solution is to check if the related document is removed from the creation, as it may be causing a duplicate error.
Drake
11 Oct, 2023, 02:20

does some document exist with that id in the related document?

debashish
12 Oct, 2023, 14:35

yes it exists

Drake
12 Oct, 2023, 17:22

that may be the duplicate error problem then...does the user have access to the document?

debashish
12 Oct, 2023, 17:39

yes user has the access.

debashish
12 Oct, 2023, 17:40

collecttion is given the with persmission of any

Drake
12 Oct, 2023, 18:21

If you remove the related document from the creation, do you get the error? You'll probably need to include some data or maybe permissions so you don't get a missing data error

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more