Back

[SOLVED] v1.4.4 Functions Body Parsed / Not Parsed

  • 0
  • Functions
Tanner Meade
3 Oct, 2023, 17:15

This change creates a big problem (at least for dart cloud functions): https://github.com/appwrite/appwrite/pull/6317

Change is here: https://github.com/open-runtimes/open-runtimes/blob/2a069cf9bec98e18a096633b5848cde12b4fe319/runtime

By assuming that the body HAS to be json parseable, all cloud functions will throw an error if the request is not json.

TL;DR
The user had an issue where their request body was not being parsed as JSON. Another user clarified that the body will only be parsed as JSON if the content type header is set to application/json. The user thanked them for the help. They also asked if the parsing of the body depends on what triggered the execution and if there were any parse errors from user events. The users then discussed the issue further and one of them opened an issue on GitHub. They mentioned that the recent changes to the system helped reduce assumptions but this issue still exists. It was pointed out that making this change will require both backend and frontend refactors. The user mentioned
Tanner Meade
3 Oct, 2023, 17:17

So everyone who has existing functions that accept string request bodies or anything not json parsable (or anyone who wants to in the future) can no longer do that.

Tanner Meade
3 Oct, 2023, 17:17

All changes to make this work going forward require not only backend refactors, but frontend changes too.

Tanner Meade
3 Oct, 2023, 17:22

It would be really nice if cloud functions stop assuming things like this. The recent big change helped reduce these assumptions by a lot, but this is still an issue.

Tanner Meade
3 Oct, 2023, 17:27
Drake
3 Oct, 2023, 18:36

this only applies to functions triggered by event...which in those cases, the body should always be JSON

Tanner Meade
3 Oct, 2023, 18:36

aahh -- make sense

Tanner Meade
3 Oct, 2023, 18:37

I thought I was getting this error though not in that situation. I'll triple check and report back.

Drake
3 Oct, 2023, 18:38

are you getting a parse error from a user event?

Tanner Meade
4 Oct, 2023, 04:02

It's not through an error. Thanks for the help. context.req.body is giving me a string, so I'm not sure what to expect. Will body be parsed / not parsed depending on what triggered the execution?

Drake
4 Oct, 2023, 04:02

Body will only be parsed as JSON if the content type header is application/json

Tanner Meade
4 Oct, 2023, 04:03

ahh gotcha -- that makes more sense.

Tanner Meade
4 Oct, 2023, 04:03

[SOLVED] v1.4.4 Functions Body Parsed / Not Parsed

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