fix(cli): run pg-delta/--experimental gate before mutex check in db schema declarative - #5828
Conversation
…chema declarative db schema declarative generate/sync ran their mutual-exclusivity flag check (db-url/linked/local, apply/no-apply) before the pg-delta --experimental gate. Go's cobra runs PersistentPreRunE (the gate) before ValidateFlagGroups (mutex check), so a conflicting-flag invocation without --experimental surfaced the wrong error in TS vs Go. Same bug class already fixed for storage ls/cp/mv/rm in CLI-1855. Swaps the order in both handlers so the gate (and the config read it depends on) runs first, fixes misleading ordering comments, and adds regression coverage for the "mutex conflict without --experimental" case. Fixes CLI-1876
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@9003d3338eeacebe5cf8ab86f2fc2afee0606ec4Preview package for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f54b2c760c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ta gate (review: #5828) generate/sync passed the raw --experimental flag into legacyRequirePgDelta instead of legacyResolveExperimental, so an env-enabled experimental session (SUPABASE_EXPERIMENTAL=true) was treated as closed. Go's gate reads viper.GetBool("EXPERIMENTAL") (db_schema_declarative.go:78), which falls back to the env var via viper.AutomaticEnv (root.go:318-334) — the same fallback legacyResolveExperimental already implements and every other pg-delta/experimental call site already uses. Now that the gate runs before the mutex check (this PR's fix), the bug surfaces as a wrong error for SUPABASE_EXPERIMENTAL=true ... --local --linked (and --apply --no-apply on sync): TS reported the gate error instead of Go's mutex error. Swap to legacyResolveExperimental in both handlers and add regression coverage for the env-fallback case.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39bc7b49b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
…TAL (review: #5828) legacyResolveExperimental/legacyResolveExperimentalWithProjectEnv used `flag || env`, so SUPABASE_EXPERIMENTAL=1 could re-open the pg-delta gate even after an explicit --experimental=false. Go's viper gives a Changed pflag priority over AutomaticEnv regardless of its value (viper@v1.21.0/viper.go:1176-1178) — the same precedence legacyResolveYes already implements for --yes=false. Add the analogous explicit-false scan for --experimental, mirroring legacyYesFlagExplicitlyFalse.
… (review: #5828) generate/sync resolved --experimental via legacyResolveExperimental (shell env only) before reading supabase/.env, so a SUPABASE_EXPERIMENTAL set only in the project .env file did not open the pg-delta gate. Go's dbDeclarativeCmd.PersistentPreRunE calls flags.LoadConfig — which runs loadNestedEnv and os.Setenv's each project-.env key — BEFORE reading viper.GetBool("EXPERIMENTAL") (db_schema_declarative.go:73-78, pkg/config/config.go:789). Load the project env first and resolve against it via legacyResolveExperimentalWithProjectEnv, matching the pattern db reset already uses for its own yes/experimental gates.
What changed
db schema declarative generate/syncran their mutual-exclusivity flag check (db-url/linked/local,apply/no-apply) BEFORE the pg-delta/--experimentalgate (legacyRequirePgDelta). Go's cobra runsPersistentPreRunE(the gate) beforeValidateFlagGroups(mutex check) — confirmed againstapps/cli-go/cmd/db_schema_declarative.goand the actualcobra@v1.10.2source — so invoking either command with conflicting flags and no--experimentalsurfaced the wrong error in the TS shell vs Go.Same bug class already fixed for
storage ls/cp/mv/rmin CLI-1855 (#5768); this mirrors that precedent as closely as the code structure allows. Declarative's gate needs a config read (legacyReadDbToml) that storage's didn't, so the check lives inline in each handler's body rather than at the.command.tslevel — moving the config read ahead of the mutex check as part of the same reorder is also more correct (Go'sPersistentPreRunEloads config unconditionally before validating flag groups too).Swaps the order in both handlers, fixes misleading ordering comments (and two stale Go line-number citations found nearby), documents the precedence in both commands'
SIDE_EFFECTS.md, and adds regression coverage for the "mutex conflict without--experimental" case in bothgenerateandsync.Fixes CLI-1876