Back

Cloud Function working until this morning

  • 0
  • Functions
  • Cloud
Abid G
2 Sep, 2024, 11:07

I have a cloud function using python and I'm sending in a string which is then parsed using json.loads. Today for some reason, whenever I sent a string, I get a 500 internal server error. I'm able to run the cloud function fine without passing in any values. I'm not sure what's happening...

TL;DR
Cloud function encountering issues with parsing requests as per the latest update to version 1.6.x. Switch to specific types like `req.body_text`, `req.body_json`, or `req.body_binary` as per your data. Ensure content-type headers match the expected behavior. Double-check your deployment changes and project ID for pinpointing server errors. Consider redeploying the function to resolve the issue.
D5
2 Sep, 2024, 11:18

Do you can try to redeploy such function?

Abid G
2 Sep, 2024, 11:22

Yeah I redeployed a few times and I'm still getting the error.

Meldiron
2 Sep, 2024, 11:22

Heyy. Do I understand correctly this seems to be the problem for you?

TypeScript
import json

data = json.loads(req.body_raw)

Also, can you please share your project ID? It helps us to look at server errors specifically in your project

Abid G
2 Sep, 2024, 11:25

Hey @D5 , I redeployed yesterday's cloud function and it worked fine!

Hey @Meldiron , I have it as req.body instead of req.body_raw! Also, I deployed the function with a small change this morning. Do you reckon that might be the issue because of the version changes? I thought cloud is on 1.5.x and not 1.6.x yet

Meldiron
2 Sep, 2024, 11:27

req.body is a bit "magical", it sets value based on content-type header. If it says JSON, it tried to parse. If it's some of binary formats like PDF or MP3, it gives binary. And String should be a fallback. Do you know what type of body content type is being sent to a function? If we know exact header I can check expected behaviour on our end.

Meldiron
2 Sep, 2024, 11:27

This can possibly be related to 1.6 upgrade. We are here to give you all the helping hand you may need to resolve this quickly. We are also active to do any bug fixes nessessary on our end.

Meldiron
2 Sep, 2024, 11:28

Alternatively, if you need a quick fix, using those specific types you expect could resolve the bug for you: String: req.body_text JSON: req.body_json Bianry: req.body_binary - if you used to receive binary, there might be some more issues with type, but error message should be very clear if that happens, and it should be a matter of 1 simple convert

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