Back

Error 500 - After added many to many relation item

  • 0
  • Self Hosted
  • Databases
  • Web
DominikStk
22 Apr, 2024, 17:51

I have a collection with the following attributes name: string isActive: boolean state: State (another collection) devices (another collection, many to many relation)

If I have not added any devices, the UpdateDocument Endpoint works without any problems. As soon as a device is added, I get an error {"message":"Server Error","code":500,"type":"general_unknown","version":"1.5.3"}

Can anyone help me?

TL;DR
Error 500 occurs when adding a device in a many-to-many relation. UpdateDocument Endpoint works without errors if no devices are added. Solution: Check for the correct value in the relationship to resolve the issue.
DominikStk
22 Apr, 2024, 17:53
TypeScript
const { mutateAsync: update, isPending } = useUpdateRental()

const document = await update({
  $id: id,
  ...formData
})

type FormValues = {
  name: string
  state: string
  devices: Models.Document
}
TypeScript
export async function updateRental(data: any) {
  try {
    const rental = await databases.updateDocument(
      appwriteConfig.databaseId,
      appwriteConfig.rentalsCollectionId,
      data.$id,
      data
    )

    if (!rental) throw Error

    return rental
  } catch (error) {
    console.log(error)
  }
}
Guille
22 Apr, 2024, 17:54

Can you see if there any information running this command: docker compose logs appwrite ?

DominikStk
22 Apr, 2024, 17:55

Yes ^^

appwrite | [Error] Method: PATCH appwrite | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId appwrite | [Error] Type: Utopia\Database\Exception appwrite | [Error] Message: Invalid value for relationship appwrite | [Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php appwrite | [Error] Line: 3979 appwrite | [Error] Timestamp: 2024-04-22T17:46:56+00:00 appwrite | [Error] Method: PATCH appwrite | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId appwrite | [Error] Type: Utopia\Database\Exception appwrite | [Error] Message: Invalid value for relationship appwrite | [Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php appwrite | [Error] Line: 3979

DominikStk
22 Apr, 2024, 17:56

Okay ...

DominikStk
22 Apr, 2024, 17:56

I did not have in mind that there is the command for the logs

DominikStk
22 Apr, 2024, 17:57

@Guille Do I have to specify something for a relation? I am currently not sending anything ... that seems to throw the 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