Back

[SOLVED] Python cloud function failing with Internal runtime error

  • 0
  • Functions
Drake
4 Aug, 2023, 17:12
TL;DR
The user had a Python cloud function that was failing with an internal runtime error. They received guidance and fixed the issue. They had a question about returning JSON data in the "message" field, but it wasn't addressed in the thread. They also had questions about using the users API, session deletion, JWT tokens, and scope permissions for an API key. The user also asked about environment variables in code and encountered a permission error. The thread ends with a suggestion to read the documentation on functions and a link provided for further assistance. Solution: The specific solution to the initial runtime error is not mentioned in the thread. However, the
zjjt
4 Aug, 2023, 17:13

i am inserting into a collection the session id and a time i wish for it to be deleted by the cloud function. It is so because i have a remember me checkbox on my ui. So i do need to create an api key

Drake
4 Aug, 2023, 17:15

it depends on the permissions on the collection and document

zjjt
4 Aug, 2023, 17:15

ok for now i put any on create and delete

zjjt
4 Aug, 2023, 17:46

@Steven i noticed i was missing some params but for now here is the error i get after fixing An error occurred: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /v1/databases/64a671fb266768330926/collections/64cbca90100c2734a432/documents (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff84d91a90>: Failed to establish a new connection: [Errno 111] Connection refused'))

zjjt
4 Aug, 2023, 17:47

i guess since the function are inside a container they cant point to the hoost localhost , ill try my ip

zjjt
5 Aug, 2023, 22:10

@Steven does appwrite cloud functions support env variables ? if so how can i refer to them in code ?

Drake
5 Aug, 2023, 22:12

Did you read the docs on functions?

zjjt
5 Aug, 2023, 22:14

@Steven Not entirely no let me get back to it then

Drake
5 Aug, 2023, 22:16

Short answer is we have function variables rather than environment variables in the current version of functions

zjjt
5 Aug, 2023, 22:17

@Steven ok let me comb the docs for it

zjjt
5 Aug, 2023, 23:38

@Steven i managed to run it and now i am stuck with a permission error An error occurred: app.649338b1262c3cbe564c@service.192.168.1.6 (role: applications) missing scope (account) i gave all scope to my api key though

zjjt
5 Aug, 2023, 23:39

i think this snippet is the culprit # Delete the session account = Account(client) delete_response = account.delete_session(session_id) print(delete_response)

Drake
6 Aug, 2023, 00:17

You should be using the users API

zjjt
6 Aug, 2023, 00:18

@Steven with a JWT, will it work since ther is no user connected to trigger this function ? it is supposed to run with CRON automatically

Drake
6 Aug, 2023, 00:23

If a user isn't triggering the function, you won't have a JWT token 🧐

zjjt
6 Aug, 2023, 00:24

@Steven indeed so how do i do the session deleting then ? i though i had to set up an API KEY for such a maintenance use case

Drake
6 Aug, 2023, 00:24

Use the users API

zjjt
6 Aug, 2023, 00:25

@Steven sorry ...i confused both as Accounts ...

zjjt
6 Aug, 2023, 00:26

@Steven Let me revert as soon as i come back

zjjt
6 Aug, 2023, 18:48

@Steven It is all good now i fixed it thanks to your guidance.

zjjt
6 Aug, 2023, 18:48

[SOLVED] Python cloud function failing with Internal runtime error

antonio84
9 Aug, 2023, 15:29

is it possible to return json data in the "message" field ?

Drake
9 Aug, 2023, 16:32

yes. if you still need help, please create a new <#1072905050399191082> post.

antonio84
12 Aug, 2023, 09:38

ok thanks

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