Back

Error in inside a function: The document data and permissions are missing

  • 0
  • Self Hosted
  • Functions
Guille
26 Nov, 2024, 20:23

I'm trying to update a document in a function with this code:

TypeScript
const document_data = {
  tipo: data.markin.type,
  updated_at: DateTime.now().toISO(),
};

const marking = await databases_user.updateDocument(
  DB_RH,
  C_MARKIN,
  data.marking.$id,
  document_data
);

The functions fails with the error: AppwriteException: The document data and permissions are missing. You must provide either document data or permissions to be updated.

So I logged document_data and I see the data is there before I send it with updateDocument

Then I have replaced the databases.php in the appwrite source code to add some debug logs, I can see the following information when the request is make:

TypeScript
appwrite  | string(2) "db" // $databaseId
appwrite  | string(10) "collection" // $collectionId
appwrite  | string(2) "id" // $documentId
appwrite  | array(0) { // $data
appwrite  | }
appwrite  | NULL // $permissions

So seems like the problem is the SDK not sending the data. But when I try the same function running it with the CLI it works without problem

I'm using:

  • appwrite 1.6.0
  • node-appwrite 14.1.0
  • bun 1.0

What can be happening?

TL;DR
Developers are encountering an error when trying to update a document within a function. The issue seems to be with the SDK not sending the data correctly, as logs show that the data is missing. This error message suggests that either document data or permissions need to be provided for the update, but the provided data seems correct. The same function works when run with the CLI. The versions being used are: `appwrite 1.6.0`, `node-appwrite 14.1.0`, and `bun 1.0`. Solution: Update the SDK to the latest version to resolve the issue with data not being sent
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