supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.02k stars 201 forks source link

Support boolean in Config.toml env substitution #1325

Open goszczynskip opened 1 year ago

goszczynskip commented 1 year ago

Describe the bug env isn't working for some config.toml keys for example enabled = env(MY_VAR) in auth section.

To Reproduce Steps to reproduce the behavior:

  1. Add following Google OAuth config in config.toml file
    [auth.external.google]
    enabled = env(GOOGLE_OAUTH_ENABLED)
    client_id = "env(GOOGLE_CLIENT_ID)"
    secret = "env(GOOGLE_SECRET)"
  2. Add .env file in the project root with envs
    GOOGLE_OAUTH_ENABLED=false
  3. Try to start supabase via supabase start command
  4. See error
    cannot read config in /[redacted]: toml: line 64 (last key "auth.external.google.enabled"): expected value but found "env" instead

Expected behavior I can start the project with auth enabled or disabled based on the env value.

Desktop (please complete the following information):

G9000 commented 9 months ago

@sweatybridge any progress on this issue? Error evaluating "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID)": environment variable SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID is unset.

sweatybridge commented 9 months ago

@G9000 that looks like a config error. env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID) is present in your config.toml but the env var is undefined. Did you forget to define the env var?

G9000 commented 9 months ago

@G9000 that looks like a config error. env(SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID) is present in your config.toml but the env var is undefined. Did you forget to define the env var?

I did, it seems not detecting at all. I saw this thread but not working for me.

sweatybridge commented 9 months ago

secret = "SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET"

That's just a static value and not using substitution.

You want to keep secret = "env(SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET)" in config.toml and try the following

SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc supabase start

Or

echo "SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc" > .env
supabase start

Or

export SUPABASE_AUTH_EXTERNAL_GOOGLE_SECRET=abc
supabase start

They all should load the env var correctly into your config.toml at runtime.