Skip to content

fix(cli): use Go's bare invalid-version error in db reset (CLI-1979) - #5969

Open
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1979-db-reset-version-non-integer-error-text-diverges-from-go
Open

fix(cli): use Go's bare invalid-version error in db reset (CLI-1979)#5969
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1979-db-reset-version-non-integer-error-text-diverges-from-go

Conversation

@Coly010

@Coly010 Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What changed

supabase db reset --version <non-integer> in the TS legacy shell emitted failed to parse <v>: invalid version number. The Go CLI's reset.Run returns the bare repair.ErrInvalidVersion = invalid version number (apps/cli-go/internal/db/reset/reset.go:35-36); the failed to parse <v>: wrapper belongs to migration repair only (apps/cli-go/internal/migration/repair/repair.go:29). This drops the wrapper on the reset path only:

  • reset.handler.ts: emit the bare invalid version number (exit code and --debug hint unchanged).
  • reset.errors.ts: JSDoc now cites the correct Go source (reset.go:35-36) instead of the repair-path lines that led to the original conflation.
  • reset.integration.test.ts: the previous toContain("invalid version number") assertion passed for both the wrapped and bare messages (so it could not catch this divergence) — it now pins the exact tag + message.
  • repair.integration.test.ts: guard assertion that migration repair keeps its failed to parse <v>: wrapper (correct Go parity there), so a future unification can't regress either side.

db reset --last validation and messages are untouched (already at parity). SIDE_EFFECTS.md for db reset already documented the bare message, so code and doc now agree.

Why

Strict 1:1 Go parity for the legacy shell. Empirically confirmed on both binaries: Go prints invalid version number, TS printed failed to parse abc: invalid version number (both exit 1). Audit ref: apps/cli/docs/go-parity-audit-2026-07-24.md §3.2 (R1).

Deliberately left open

Reviewers noted a pre-existing, adjacent divergence: the reset path's INTEGER_PATTERN accepts >int64 numeric versions (e.g. 20 digits) that Go's strconv.Atoi rejects with invalid version number; TS instead falls through to the glob file does not exist error. migration repair already solves this via the shared legacyParseMigrationVersion helper. Out of CLI-1979's scope (wrapper text only) — candidate for a follow-up issue.

Fixes CLI-1979

https://linear.app/supabase/issue/CLI-1979/db-reset-version-non-integer-error-text-diverges-from-go

Go's reset.Run returns the bare repair.ErrInvalidVersion ("invalid
version number", reset.go:35-36); the "failed to parse <v>:" wrapper
belongs to migration repair only (repair.go:29). Drop the wrapper on
the db reset path, pin the exact message in the reset integration
test, and add a guard assertion that migration repair keeps its
wrapper.
@Coly010

Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 40c81767e3

ℹ️ 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".

@Coly010 Coly010 self-assigned this Jul 28, 2026
@Coly010
Coly010 marked this pull request as ready for review July 28, 2026 11:26
@Coly010
Coly010 requested a review from a team as a code owner July 28, 2026 11:26
@github-actions

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@40c81767e3ee4d02b31ce6ba0b714d67046dd2e7

Preview package for commit 40c8176.

@kanadgupta kanadgupta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tiny behavioral divergence that Claude discovered (see below) but otherwise LGTM

return yield* Effect.fail(
new LegacyDbResetInvalidVersionError({
message: `failed to parse ${v}: invalid version number`,
message: "invalid version number",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The message now byte-matches Go, but the condition still diverges from Go's strconv.Atoi in two edge cases, so this exact error isn't emitted in exactly the cases Go emits it:

  • int64 overflowAtoi == ParseInt(s, 10, 0), which rejects values outside the int64 range, so Go's db reset --version 99999999999999999999 fails with this bare invalid version number (reset.go:35-36). INTEGER_PATTERN (/^[+-]?\d+$/u, line 51) accepts it, so the TS path falls through to the glob check and reports glob supabase/migrations/…: file does not exist instead.
  • empty version — Go guards with len(version) > 0 (reset.go:34), so an empty --version skips validation entirely and proceeds; here Option.isSome + the regex turn it into this error.

There's already a shared exact-Atoi mirror for this: legacyParseMigrationVersion (src/legacy/shared/legacy-migration-timestamp.format.ts:64), which migration repair uses for this same validation (repair.handler.ts:186 — repair's tests even pin the 20-digit overflow case). Replacing the INTEGER_PATTERN.test(v) check with legacyParseMigrationVersion(v) === undefined (plus a v.length > 0 guard mirroring reset.go:34) would close both gaps and drop the duplicated regex.

Both divergences predate this PR, so a follow-up is fine if you'd rather keep this diff minimal — but since the ticket's goal is byte-parity on this exact error path, worth tracking.

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.

2 participants