fix(cli): match Go's init error texts for already-exists and orioledb gate (CLI-1986) - #5977
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b81bf4ce3
ℹ️ 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".
| detail: `Config already exists at ${result.configPath}.`, | ||
| suggestion: "Run `supabase init --force` to overwrite the existing config.", | ||
| new LegacyInitConfigExistsError({ | ||
| message: "failed to create config file: open supabase/config.toml: file exists", |
There was a problem hiding this comment.
Render the existing-config error per platform
On the published Windows targets, Go constructs ConfigPath with filepath.Join and surfaces the Windows os.PathError, so this hard-coded POSIX message outputs both the wrong path separator and the wrong errno text whenever supabase/config.toml already exists. Select the message using the runtime platform (and cover Windows in the integration test) rather than knowingly limiting the legacy shell's strict output parity to Linux/macOS.
AGENTS.md reference: apps/cli/AGENTS.md:L248-L256
Useful? React with 👍 / 👎.
What changed
supabase init's two error paths on the legacy shell now byte-match the Go CLI (verified by building and runningapps/cli-golocally):Config already exists (no
--force) — was a friendlier TS-only message; now:This is Go's wrapped
O_EXCL*os.PathErrorfromutils.InitConfig(config.go:243-246) plus theCmdSuggestionfrominternal/init/init.go:38-42. The path is Go's relativeutils.ConfigPath, so it's constant regardless of cwd/--workdir.--use-orioledbwithout--experimental— wasThe --use-orioledb flag requires --experimental.; now cobra's message from Go'sPreRunMarkFlagRequired("experimental")(cmd/init.go:32-36):The second line is Go's generic
recoverAndExitdebug hint, which the legacy text output layer already appends when an error carries no suggestion. This follows the same handler-level convention asdb dump'sdata-onlygate andvanity-subdomains'desired-subdomaingate (bare message, noError:prefix — matching Go'sSilenceErrors+recoverAndExitrendering, verified against the built binary).Also fixed while there (issue scope): the shared gitignore append now always prepends
\nwhensupabase/.gitignoreexists — even when it's empty — matchinginternal/init/init.go:80-96(verified against the built Go binary).Shell-scoping decision
The shared
initProjectmodule stays mechanism-only (it already returned{ created: false }and left error shaping to each shell). Error shaping lives at each shell's handler boundary:legacy/commands/init/init.errors.tswith Go's exact bytes.Supabase project already initialized.no-op andThe --use-orioledb flag requires --experimental.— now pinned by tests. ItsInitExperimentalRequiredErrormoved fromshared/tonext/commands/init/init.errors.tssince it's next-only after this change; the now-unused sharedInitAlreadyExistsErrorwas deleted.The gitignore newline fix is in shared code and applies to both shells (mechanical scaffolding, same bytes as Go).
Notes / deliberately left open
The file exists.). Documented inSIDE_EFFECTS.mdand the error's docstring.normalize-error.ts'sMissingOptioncase rendersError: required flag(s) … not setwith anError:prefix, while the built Go binary prints no prefix viarecoverAndExit— worth a separate parity check;apps/cli/CLAUDE.md's porting checklist quotes a stale debug-hint wording ("get more details" vs the actual "troubleshoot the error"); Go'sfailed to read git ignore fileerror branch for an unreadable existing.gitignoreremains unported.Fixes CLI-1986
Linear: https://linear.app/supabase/issue/CLI-1986/init-error-texts-diverge-from-go-already-exists-use-orioledb-gate