cli icon indicating copy to clipboard operation
cli copied to clipboard

env() does not work in config.toml arrays

Open schwartzadev opened this issue 1 year ago • 1 comments

Describe the bug The env() function to load environment variables into the config.toml does not work for arrays in the config.toml.

To Reproduce Steps to reproduce the behavior:

  1. Add this to the project config.toml
[db.seed]
enabled = true
sql_paths = [
    "env(SEEDS_PATH)"
]
  1. Run SEEDS_PATH=abc123 supabase db reset
  2. Observe No seed files matched pattern: supabase/env(SEEDS_PATH) in the console output. This is the first line in the output.

Expected behavior Supabase uses the path in the environment variable to source database seeds.

System information Rerun the failing command with --create-ticket flag.

  • Ticket ID: This does not output from running SEEDS_PATH=abc123 supabase db reset --create-ticket
  • Version of OS: Mac 14.4 (23E214)
  • Version of CLI: 1.204.3
  • Version of Docker: Docker version 27.2.0, build 3ab4256
  • Versions of services:

  
        SERVICE IMAGE      │      LOCAL       │   LINKED
  ─────────────────────────┼──────────────────┼─────────────
    supabase/postgres      │ 15.1.0.122       │ 15.1.0.122
    supabase/gotrue        │ v2.162.1         │ v2.162.1
    postgrest/postgrest    │ v11.2.0          │ v11.2.0
    supabase/realtime      │ v2.30.34         │ -
    supabase/storage-api   │ v1.11.7          │ v1.11.14
    supabase/edge-runtime  │ v1.58.12         │ -
    supabase/studio        │ 20240930-16f2b8e │ -
    supabase/postgres-meta │ v0.83.2          │ -
    supabase/logflare      │ 1.4.0            │ -
    supabase/supavisor     │ 1.1.56           │ -

Additional context I have tested this with a .env file as well, with no luck.

Related issues include:

  • https://github.com/supabase/cli/issues/1551
  • https://github.com/supabase/cli/issues/1325
  • https://github.com/supabase/cli/issues/278
  • https://github.com/supabase/cli/issues/210

These issues are related but distinct -- as far as I can tell there is no issue for this array-specific bug.

schwartzadev avatar Oct 16 '24 19:10 schwartzadev

I've run into the same issue

0reo avatar Oct 23 '24 19:10 0reo

May I clarify if your use case is to change seed files based on different environments?

Instead of customising each field by env var, we probably want to offer a more reliable alternative like SUPABASE_PROJECT_ID=some-ref supabase db reset which would customise all configs for a specific project.

sweatybridge avatar Nov 15 '24 11:11 sweatybridge

Any updates on this? This also happens when env() is used as part of a string like so env(ENV_VAR)/api/some-endpoint. This may be related to the regex used here to match the env function.

Fadi729 avatar Dec 21 '24 12:12 Fadi729