appwrite / appwrite

Your backend, minus the hassle.
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
44.35k stars 3.96k forks source link

creating Nested documents returns 500 Server error #1213

Closed Sameerkash closed 2 years ago

Sameerkash commented 3 years ago

🐛 Bug Report

(A clear and concise description of what the bug is)

Trying to create a nested document throws an internal server error, the same request with

To Reproduce

Expected behavior

Successful document creation

Actual Behavior

500 Internal Server error

logs

| [Error] Timestamp: 2021-05-28T14:47:21+00:00

appwrite | [Error] Method: POST

appwrite | [Error] URL: /v1/database/collections/:collectionId/documents

appwrite | [Error] Type: TypeError

appwrite | [Error] Message: Argument 1 passed to Appwrite\Database\Database::encode() must be an instance of Appwrite\Database\Document, array given, called in /usr/src/code/src/Appwrite/Database/Database.php on line 502

appwrite | [Error] File: /usr/src/code/src/Appwrite/Database/Database.php

appwrite | [Error] Line: 476

Your Environment

ghost commented 3 years ago

Has the source of this bug already been identified, and do we know if creating nested documents via POST has worked in previous builds? I am experiencing the same behavior while hoping to utilize AppWrite DB; I'm running Appwrite 0.8.0 on Ubuntu Server 20.04. I would be happy to look into resolving this issue, but I want to ensure there isn't some key historical detail I'm missing about this feature. Let me know.

TorstenDittmann commented 3 years ago

Has the source of this bug already been identified, and do we know if creating nested documents via POST has worked in previous builds? I am experiencing the same behavior while hoping to utilize AppWrite DB; I'm running Appwrite 0.8.0 on Ubuntu Server 20.04. I would be happy to look into resolving this issue, but I want to ensure there isn't some key historical detail I'm missing about this feature. Let me know.

Hey, this issue got a bit lost 😕

iirc, I had trouble re-creating the bug when I took a look at it. Do you mind sharing the JSON of your collections? @jfeversole

ghost commented 3 years ago

@TorstenDittmann That's no problem! I reviewed more issues here in this tracker related to nested documents and have identified that it's very unlikely that the bug I faced yesterday is an actual Appwrite bug rather than one I introduced with my document structure. I saw this as "Open" and "Assigned" and incorrectly assumed this is a known problem with the software rather than a one-off bug report. You know what they say about assuming!

I will be going back to review the documents I was trying to create while reviewing the related issues in this tracker. If I'm still having problems by that point and have reason to believe it's an AppWrite problem and not a "me" problem, I'll be sure to post plenty of debugging info.

nico87 commented 2 years ago

@jfeversole Did you find out what the problem was? I'm struggling with the same issue creating an embedded document. I can create the embedded document via the UI but it's not linked to its parent document.

ghost commented 2 years ago

@nico87 The issues I experienced here led to me dropping AppWrite from my project, so unfortunately not. Embedded documents were too important for what I was creating and even the simplest of JSON structure would fail to work here in my testing.

nico87 commented 2 years ago

Thanks @jfeversole . In the end I solved the issues I was facing. Basically, I didn't add the $collection and $permissions keys to the documents I was saving. After that, the nested documents are saved correctly.

TorstenDittmann commented 2 years ago

Since we removed nested documents this issue is not relevant anymore 👍🏻