Back

Error when creating document which contains already existing nested document

  • 1
  • Databases
  • Apple
yousuf
1 Oct, 2024, 03:38

Hi, I am running into some issues when trying to create a document which contains an already existing nested document (i.e. the nested documentId exists in the database). Appwrite throws an error saying The current user is not authorized to perform the requested action.

Here are some more details:

  • All collections have the permission Role("any")
  • When creating a document that contains an already existing nested document (existing documentId), I get the error "The current user is not authorized to perform the requested action."
  • When deleting that nested document from the database and trying to create the same document, the creation is successful. Or when creating the same document but without the nested document, the creation is also successful.

According to the docs:

TypeScript
If a nested child document is included and the child document ID already exists, the child document will be updated.

(https://appwrite.io/docs/products/databases/relationships#create-documents:~:text=If%20a%20nested%20child%20document%20is%20included%20and%20the%20child%20document%20ID%20already%20exists%2C%20the%20child%20document%20will%20be%20updated.)

There was an unresolved support ticket regarding this from a year ago. Is there any update? What are some alternatives I can take in the meantime?

TL;DR
Issue: Error occurs when creating a document with an already existing nested document. Appwrite displays a message saying "The current user is not authorized to perform the requested action." The collections have the permission Role("any"). When trying to create a document with an existing nested document (documentId), the error appears. The docs state that if a nested child document already exists, it should be updated. Solution: Try deleting the nested document and then creating the document. Alternatively, try creating the document without the nested document, which should be successful. No updates on the unresolved ticket.
Steven
1 Oct, 2024, 03:43

Please share an appwrite.json with your collections and the request you're making

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