#Server Error when updating an existing document via UpsertDocument
19 messages · Page 1 of 1 (latest)
what's your project ID?
messaged you
What's your code?
the project id is 688ff2ab001d8312a1ef. I DM'd you the function id and a successful vs error execution id (one creating the document, the next attempting to update it)
Maybe the user doesn't have access
Hmm, I'm using the function's dynamic API key, which has documents.read and documents.write permissions. Is there a specific permission for upsert that I'm missing?
Oh interesting...I've definitely seen it work. That's odd you're having this error...
I created a test project in attempt to replicate the issue and found that UpsertDocument works at intended... Which is odd, as I'm certain the issue was being thrown at Upsert document in my other project. Maybe it was because of a specific attribute or permission. I'll dive deeper into it and see what I can find. Thanks for your help.
Ok, I figured it out. If the data of the document is the same, the server error is thrown.
Full source of project:
https://github.com/Colton127/upsert_document_test/blob/main/lib/main.dart
The commit that introduced the error changed saving data dynamic data to static:
https://github.com/Colton127/upsert_document_test/commit/fe79ba2d54d95d607d50d14040f41235206a0903
The associated functionId is 689508c30014b2cc1e50
One solution is to see if the document already exists, and if so, compare the data to check for changes. But I'd rather avoid unnecessary server requests.
💯 i don't think it should fail. I'll need to look into this and reproduce. One thing that would help is if you create a github issue with these details
ok weird...i tried an upsert with an existin value but it worked fine..
im making the api call manually though
I think I found what might be causing it: https://github.com/utopia-php/database/blob/33f35f5daeebd587f79abf362cfb512b9df3cd50/src/Database/Database.php#L5036-L5039
Have you created a github issue for this?
👟 Reproduction steps Create a document using any method, including Upsert Document Call UpsertDocument with the same document id and data Full replication source code: https://github.com/Colton127/...
🙏🏼 I've escalated this to the team
How is it now?