Back
Error on python function: local variable 'path' referenced before assignment
- 0
- Self Hosted
- Functions
thet3o
I don't know how to resolve it, there isn't any path variable
TypeScript
import json
from appwrite.client import Client
from appwrite.services.databases import Databases
from appwrite.services.users import Users
from appwrite.id import ID
from appwrite.services.teams import Teams
def main(req, res):
# Environment variables
payload = json.loads(req.variables.get('APPWRITE_FUNCTION_EVENT_DATA'))
endpoint = req.variables.get("APPWRITE_ENDPOINT")
project_id = req.variables.get("APPWRITE_PROJECT_ID")
api_key = req.variables.get("APPWRITE_API_KEY")
database_id = req.variables.get('DATABASE_ID')
users_collection_id = req.variables.get('USERS_COLLECTION_ID')
customers_team_id = req.variables.get("CUSTOMERS_TEAM_ID")
#Client Databases Users and Teams initialization
...
try:
database.get_document(database_id, users_collection_id, payload['userId'])
except Exception:
try:
print(payload['userId'])
userId = payload['userId']
user_data = user.get(user_id=userId)
print(user_data)
team.create_membership(
team_id=customers_team_id,
roles=[],
email=user_data['email'],
user_id=payload['userId'],
url='https://test.justitis.it',
name=user_data['name'],
)
database.create_document(
database_id=database_id,
collection_id=users_collection_id,
document_id=payload['userId'],
data={
'userId':payload['userId'],
'name':user_data['name'],
'email':user_data['email'],
}
)
except Exception as e:
print(str(e))
TL;DR
The user is experiencing an error in their Python function where the local variable 'path' is referenced before assignment. Other users suggest trying to use version 2.0.2 of the SDK, but it's unclear if this will fix the issue. The support team acknowledges there is an issue with the SDKs and they are working on a fix. The user is unsure how to resolve the error because they don't see a 'path' variable.
Solution: It's unclear what the exact issue is without more information. The user may need to provide more context or debug the code further to identify the cause of the error. Drake
There's an issue with SDKs at the moment. we need to push out a fix.
thet3o
ah ok, thank you!
thet3o
if I use 2.0.2 it maybe work right?
Recommended threads
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...
- Create admin user?
I'm not really sure how this is supposed to work, I installed Appwrite through docker-compose and set it up. When I launched the app and went into it, I created...