Rank 3: Container
I get the error to the update a relationship: Invalid document structure: Missing collection attribute $collection (400)
Votes
0
Replies
19
Participants
Unknown
Messages
20
Rank 3: Container
I get the error to the update a relationship: Invalid document structure: Missing collection attribute $collection (400)
Admin
Is this a clean install or did you upgrade?
Rank 3: Container
Upgrade 1.3.1 to 1.3.3
Admin
Did you run the migrate command after?
Rank 3: Container
Yes
Admin
Does it work in the console but not in your app?
Rank 3: Container
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
Admin
What type of relationship?
Rank 3: Container
one to many
Admin
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
Admin
ok i was able to reproduce after migrating...time to troubleshoot...
Admin
here's the stacktrace from the API call:
{ "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": [ {}, {} ] } ]}Admin
appwrite logs:
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
Admin
that's odd this worked on my previous instance 🧐
Rank 3: Container
Ohh that strange, the error was thrown at me even without doing the migration.
Ready friend. I will wait for this solution. Thanks
Admin
You definitely needed to run the 1.3.3 migration going from 1.3.1 to 1.3.3. What migrations did you run?
Rank 3: Container
cd appwrite/
docker compose exec appwrite migrate
Rank 3: Container
I thought this would fix the error but it stayed
Admin
ok....i actually don't think it's a migration problem...just a bug with relationships..
Admin
here's the issue: https://github.com/appwrite/appwrite/issues/5478