Back

error relationship on 1.3.3 version

  • 0
  • Databases
  • Flutter
hortigado
29 Apr, 2023, 06:05

I get the error to the update a relationship: Invalid document structure: Missing collection attribute $collection (400)

TL;DR
Issue: Error thrown when updating a relationship, specifically "Invalid document structure: Missing collection attribute $collection" (400). - User tried running the migration command `cd appwrite/ docker compose exec appwrite migrate` but the error persisted. - The error is thrown even without running the migration. - Stacktrace from the API call is provided for reference. - User tried reproducing the error on their local instance but couldn't. - User is planning to create a fresh 1.3.1 instance, upgrade, and test again. - The error occurs when adding a child to a parent relationship, but not when adding a parent to
Drake
29 Apr, 2023, 14:55

Is this a clean install or did you upgrade?

hortigado
29 Apr, 2023, 14:56

Upgrade 1.3.1 to 1.3.3

Drake
29 Apr, 2023, 14:56

Did you run the migrate command after?

hortigado
29 Apr, 2023, 14:56

Yes

Drake
29 Apr, 2023, 14:57

Does it work in the console but not in your app?

hortigado
29 Apr, 2023, 15:11

correct also throws the error when adding a document to the relation. But it only happens when a child is added from the parent. But it does not throw the arror to add a parent to the child document

Drake
29 Apr, 2023, 15:13

What type of relationship?

hortigado
29 Apr, 2023, 15:15

one to many

Drake
29 Apr, 2023, 16:27

I did a quick test on my local instance, but i couldn't reproduce...Let me try to create a 1.3.1 instance, upgrade, and test again

Drake
29 Apr, 2023, 16:29

ok i was able to reproduce after migrating...time to troubleshoot...

Drake
29 Apr, 2023, 16:32

here's the stacktrace from the API call:

TypeScript
{
  "message": "Invalid document structure: Missing collection attribute $collection",
  "code": 400,
  "type": "document_invalid_structure",
  "version": "1",
  "file": "/usr/src/code/app/controllers/api/databases.php",
  "line": 3387,
  "trace": [
    {
      "file": "/usr/src/code/vendor/utopia-php/framework/src/App.php",
      "line": 577,
      "function": "{closure}",
      "args": [
        "one-to-many",
        "level2",
        "level2",
        {
          "$permissions": [
            "read(\"user:644c188e597dbee6ee8c\")",
            "update(\"user:644c188e597dbee6ee8c\")",
            "delete(\"user:644c188e597dbee6ee8c\")"
          ],
          "level1": {
            "$id": "level1",
            "$createdAt": "2023-04-28T19:07:31.749+00:00",
            "$updatedAt": "2023-04-28T19:07:31.749+00:00",
            "$permissions": [
              "read(\"user:644c188e597dbee6ee8c\")",
              "update(\"user:644c188e597dbee6ee8c\")",
              "delete(\"user:644c188e597dbee6ee8c\")"
            ],
            "$databaseId": "one-to-many",
            "$collectionId": "level1"
          },
          "level3": [
            "level3"
          ],
          "$collection": "level2",
          "$createdAt": "2023-04-28T19:07:31.750+00:00",
          "$id": "level2"
        },
        [
          "read(\"user:644c188e597dbee6ee8c\")",
          "update(\"user:644c188e597dbee6ee8c\")",
          "delete(\"user:644c188e597dbee6ee8c\")"
        ],
        null,
        {},
        {},
        {},
        "admin"
      ]
    },
    {
      "file": "/usr/src/code/vendor/utopia-php/framework/src/App.php",
      "line": 755,
      "function": "execute",
      "class": "Utopia\\App",
      "type": "->",
      "args": [
        {},
        {}
      ]
    },
    {
      "file": "/usr/src/code/app/http.php",
      "line": 252,
      "function": "run",
      "class": "Utopia\\App",
      "type": "->",
      "args": [
        {},
        {}
      ]
    }
  ]
}
Drake
29 Apr, 2023, 16:32

appwrite logs:

TypeScript
appwrite  | [Error] Timestamp: 2023-04-29T16:29:07+00:00
appwrite  | [Error] Method: PATCH
appwrite  | [Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
appwrite  | [Error] Type: Appwrite\Extend\Exception
appwrite  | [Error] Message: Invalid document structure: Missing collection attribute $collection
appwrite  | [Error] File: /usr/src/code/app/controllers/api/databases.php
appwrite  | [Error] Line: 3387
Drake
29 Apr, 2023, 16:34

that's odd this worked on my previous instance 🧐

hortigado
29 Apr, 2023, 16:42

Ohh that strange, the error was thrown at me even without doing the migration. Ready friend. I will wait for this solution. Thanks

Drake
29 Apr, 2023, 16:42

You definitely needed to run the 1.3.3 migration going from 1.3.1 to 1.3.3. What migrations did you run?

hortigado
29 Apr, 2023, 16:44

cd appwrite/ docker compose exec appwrite migrate

hortigado
29 Apr, 2023, 16:44

I thought this would fix the error but it stayed

Drake
1 May, 2023, 17:09

ok....i actually don't think it's a migration problem...just a bug with relationships..

Drake
1 May, 2023, 17:19
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