Closed djbensono closed 2 months ago
Hi there,
First please ensure that you've added the environment variables to your deployed app environment as it differs from how environment variables are accessed in a local-run environment
To access environment variables within a custom function, you'll want to use the 'env' context property as shown here
Thanks, but I have previously added all required environment variables by using the slack var add
command. Running slack env list
shows me all required environment variables:
There are 7 variables stored in this environment
ADMIN_EMAIL: ******
CALENDAR_EMAIL: ******
CHANNEL_ID: ******
DAILY_SCHEDULE_START: ******
OAUTH_CLIENT_ID: ******
OAUTH_CLIENT_SECRET: ******
OAUTH_TENANT_ID: ******
This appears to be a permissions to access environment variables error - not the fact that they are missing.
@djbensono there is a slight misunderstanding here.
When deployed to Slack, the deno runtime does not get environment reading permissions. That is, if your deno code executes Deno.env.get
, it will inevitably fail when slack deploy
ed, because we explicitly prevent accessing them on Slack infra.
Instead:
slack var add
(as you've done) - this will ensure that slack deploy
ed version of the app gets env vars provided not as an environment variable available via Deno.env.get()
but as a function parameter. Please see the link @vegeris provided you for an example of how to use these variables..env
file listing these variables out (as per the example here). Use the same function-argument approach to read these values as you would for step 1.I will close this issue as I believe this is resolved. If you have any further questions, feel free to re-open or file a new issue.
The
deno-slack
versions"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.10.0/", "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.4.0/",
Deno runtime version
deno 1.43.2 (release, x86_64-unknown-linux-gnu) v8 12.4.254.12 typescript 5.4.5
OS info
Ubuntu 22.04.4 LTS
Describe the bug
I have an app that uses environment variables within a user-defined module that is called from within a Slack function. My app works fine locally (
slack run
) however upon executing the function from a deployed app (slack deploy
) I receive the following errors:I am accessing the environment variables as follows:
My
slack.json
file is as follows: