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

Is this a clean install or did you upgrade?

Upgrade 1.3.1 to 1.3.3

Did you run the migrate command after?

Yes

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

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

What type of relationship?

one to many

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

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

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": [
{},
{}
]
}
]
}

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

that's odd this worked on my previous instance 🧐

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

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

cd appwrite/ docker compose exec appwrite migrate

I thought this would fix the error but it stayed

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

here's the issue: https://github.com/appwrite/appwrite/issues/5478
Recommended threads
- Appwrite isn't accepting the api from se...
Error creating user: AppwriteException: Server Error type: 'general_unknown', response: '{"message":"Server Error","code":500,"type":"general_unknown","versi...
- Subject: Request for temporary quota lif...
Hi Appwrite Team, our nonprofit animal rescue app on Appwrite Cloud is currently throttled due to read‑quota limits, and we need a temporary increase so rescue ...
- Console create row ui not passing ID.uni...
I'm getting an error saying the id is already used but it should be created with ID.unique() it doesn't seem to be reading the row ID field at all. I can't get ...
