Back

Getting Message: Invalid value for relationship

  • 0
  • Databases
  • Self Hosted
Vedsaga
30 Jul, 2023, 15:17
TypeScript
appwrite  | [Error] File: /usr/src/code/app/controllers/api/databases.php
appwrite  | [Error] Line: 848
appwrite  | [Error] Timestamp: 2023-07-30T15:08:07+00:00
appwrite  | [Error] Method: GET
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId
appwrite  | [Error] Type: Appwrite\Extend\Exception
appwrite  | [Error] Message: Collection with the requested ID could not be found.
appwrite  | [Error] File: /usr/src/code/app/controllers/api/databases.php
appwrite  | [Error] Line: 848
appwrite  | [Error] Timestamp: 2023-07-30T15:13:55+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110
appwrite  | [Error] Timestamp: 2023-07-30T15:14:15+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110
appwrite  | [Error] Timestamp: 2023-07-30T15:14:33+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110

While trying to update the enum via console getting this error...

TL;DR
Issue: User is getting an "Invalid value for relationship" error while trying to update a collection in Appwrite. The error occurred after deleting documents in the collection that had relationships with other collections. Solution: It seems that deleting documents with relationships caused the issue. To fix it, the user should check the database and make sure there are no documents with invalid relationship values. If there are, the user should update or remove those documents to resolve the error. Additionally, it is advised to avoid deleting documents that are referenced by other documents to prevent this error from occurring in the future.
Vedsaga
30 Jul, 2023, 15:20
Vedsaga
30 Jul, 2023, 15:20

also, server error while trying to update the document

Vedsaga
30 Jul, 2023, 15:22

for this video this is the below log

TypeScript
appwrite  | [Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
appwrite  | [Error] Line: 3110
appwrite  | [Error] Timestamp: 2023-07-30T15:20:00+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110
appwrite  | [Error] Timestamp: 2023-07-30T15:20:24+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110
appwrite  | [Error] Timestamp: 2023-07-30T15:21:06+00:00
appwrite  | [Error] Method: DELETE
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: Appwrite\Extend\Exception
appwrite  | [Error] Message: Document cannot be deleted because it is referenced by another document.
appwrite  | [Error] File: /usr/src/code/app/controllers/api/databases.php
appwrite  | [Error] Line: 3542
appwrite  | [Error] Timestamp: 2023-07-30T15:21:17+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: 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: 3110
Drake
30 Jul, 2023, 17:35

What version of Appwrite?

Vedsaga
30 Jul, 2023, 17:35

1.3.7

Drake
30 Jul, 2023, 17:37

Hmm I thought this wasn't a problem anywhere...

Would you please provide reproducible steps?

mav8rick
6 Nov, 2023, 20:05

I had the same issue (v1.3.7) . It seems like this: I have setup collection A with relationships to 2 other collections with "Restrict - document can not be deleted"

Then we deleted documents in collection A (we were new, didn't know what we were doing) and then we started getting errors like:

TypeScript
appwrite  | [Error] Timestamp: 2023-11-06T19:59:31+00:00
appwrite  | [Error] Type: Utopia\Exception
appwrite  | [Error] Message: Not Found
appwrite  | [Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
appwrite  | [Error] Line: 803

and now we are hit with this when we try to update collection A:

TypeScript
appwrite  | [Error] Type: 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: 3090
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