For some reason my globally defined env variables are not available in my functions. I have tried to:
- Delete and recreate the variables
- Restart all containers
- Use local variables for the functions
- Redeploy the function But still none of these actions fixed the issue. I'm logging the variables like this:
const client = new Client()
.setEndpoint(process.env.APPWRITE_ENDPOINT ?? '')
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID ?? '')
.setKey(process.env.APPWRITE_API_KEY ?? '');
log(process.env.APPWRITE_ENDPOINT);
log(process.env.APPWRITE_FUNCTION_PROJECT_ID);
log(process.env.APPWRITE_API_KEY);
But the output the env variables are all empty strings except for APPWRITE_FUNCTION_PROJECT_ID. I'm using version 1.4.5. I see this issue was posted earlier: https://discord.com/channels/564160730845151244/1146971163403223040 But was not really resolved.
So I found out that all local variables also don't work in the functions. I looked at the logs of appwrite-worker-builds and I can see that the variables are available when building the function. Not sure if I can do anything else to debug this
Where are you defining the variables?
I have defined them globally under Project -> Settings. This used to work but suddenly stopped working since yesterday Defining variables in the functions themselves also does not work anymore
I'm unable to reproduce this on either cloud or self-hosted
APPWRITE_FUNCTION_PROJECT_ID
is generated automatically by Appwrite - there's no need to set it manually. Probably none of your vars are being set.
Yeah I was also thinking that. I don't know enough about the containers to really debug this, would you have any idea?
Just to check - you're not seeing any errors, are you?
Usage is causing internal server errors but I don't expect it to be related to this issue
Nah, I don't think so. Nothing in the error logs in the Execution?
In the function itself I see this error
Error: Unable to connect. Is the computer able to access the url?
Which is as expected because the endpoint url is empty
Besides that I see this error in traefik:
time="2023-11-07T04:56:11Z" level=error msg="Error while Peeking first byte: read tcp <ip>:80-><ip2>:38894: read: connection timed out"
Not sure what traefik is used and if it can relate to my issue
Did you replace <ip>
and <ip2>
? What were they pointing to originally?
was this function created before 1.4?
At some point I did migrate from v 1.3.x to 1.4.5 but the functions were working fine until 2 days ago. The same issue is happening for newly created functions
Thinking about it I did set the value of _APP_OPENSSL_KEY_V1, this is probably also used to encrypt environment variables. So me setting this value probably caused the issues, could that be the case?
Yes, if you change the value, all previous encrypted values will no longer be valid
[SOLVED] Global env variables are not working in functions
Recommended threads
- Migrate from cloud to localhost
Hello everyone. I need to migrate my test project from cloud to localhost, however it seems that this is possible only if a self-hosted appwrite instance it's h...
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- 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...