Skip to content

fix(cli): match Go's init error texts for already-exists and orioledb gate (CLI-1986) - #5977

Draft
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1986-init-error-texts-diverge-from-go-already-exists-use-orioledb
Draft

fix(cli): match Go's init error texts for already-exists and orioledb gate (CLI-1986)#5977
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1986-init-error-texts-diverge-from-go-already-exists-use-orioledb

Conversation

@Coly010

@Coly010 Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What changed

supabase init's two error paths on the legacy shell now byte-match the Go CLI (verified by building and running apps/cli-go locally):

  1. Config already exists (no --force) — was a friendlier TS-only message; now:

    failed to create config file: open supabase/config.toml: file exists
    Run supabase init --force to overwrite existing config file.
    

    This is Go's wrapped O_EXCL *os.PathError from utils.InitConfig (config.go:243-246) plus the CmdSuggestion from internal/init/init.go:38-42. The path is Go's relative utils.ConfigPath, so it's constant regardless of cwd/--workdir.

  2. --use-orioledb without --experimental — was The --use-orioledb flag requires --experimental.; now cobra's message from Go's PreRun MarkFlagRequired("experimental") (cmd/init.go:32-36):

    required flag(s) "experimental" not set
    Try rerunning the command with --debug to troubleshoot the error.
    

    The second line is Go's generic recoverAndExit debug hint, which the legacy text output layer already appends when an error carries no suggestion. This follows the same handler-level convention as db dump's data-only gate and vanity-subdomains' desired-subdomain gate (bare message, no Error: prefix — matching Go's SilenceErrors + recoverAndExit rendering, verified against the built binary).

Also fixed while there (issue scope): the shared gitignore append now always prepends \n when supabase/.gitignore exists — even when it's empty — matching internal/init/init.go:80-96 (verified against the built Go binary).

Shell-scoping decision

The shared initProject module 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 gets new legacy-scoped error classes in legacy/commands/init/init.errors.ts with Go's exact bytes.
  • Next deliberately keeps its friendlier texts: the graceful Supabase project already initialized. no-op and The --use-orioledb flag requires --experimental. — now pinned by tests. Its InitExperimentalRequiredError moved from shared/ to next/commands/init/init.errors.ts since it's next-only after this change; the now-unused shared InitAlreadyExistsError was deleted.

The gitignore newline fix is in shared code and applies to both shells (mechanical scaffolding, same bytes as Go).

Notes / deliberately left open

  • Windows: byte parity for the already-exists message is scoped to Linux/macOS (Windows Go prints its own path separator and errno text, e.g. The file exists.). Documented in SIDE_EFFECTS.md and the error's docstring.
  • Pre-existing, out of scope (flagged during review): normalize-error.ts's MissingOption case renders Error: required flag(s) … not set with an Error: prefix, while the built Go binary prints no prefix via recoverAndExit — 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's failed to read git ignore file error branch for an unreadable existing .gitignore remains unported.

Fixes CLI-1986
Linear: https://linear.app/supabase/issue/CLI-1986/init-error-texts-diverge-from-go-already-exists-use-orioledb-gate

@Coly010

Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant