fix(cli): render Go's caret, Detail, and 42704 hint in migration-apply errors - #5967
Conversation
…y errors (CLI-1977)
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edeac810b7
ℹ️ 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".
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@dd66eaef37cc2f14b1e5a5539da9c68b2e385b05Preview package for commit |
…o pgconn (review: pg-protocol S/V thread)
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
What changed
A failed migration statement in
db push/db reset(remote migrate) /migration up|downnow renders the same failure text as the Go CLI's(*MigrationFile).ExecBatch(apps/cli-go/pkg/migration/file.go:88-132), byte-for-byte:Previously the TS apply path emitted only
<driver text>\nAt statement: <i>\n<stat>— and with the real driver the head line was literallyeffect/sql/SqlError: Failed to execute statement. No caret, noDetail, no 42704 hint.legacy-db-connection.sql-pg.layer.ts): a server ErrorResponse found on theSqlErrorcause chain is now rendered as pgconn'sPgError.Error()—<Severity>: <Message> (SQLSTATE <Code>)(pgconnerrors.go:51) — andLegacyDbExecErrorcarries the structureddetail/positionfields (detailonly when non-empty,positiononly when > 0, matching Go's gates). Non-server failures keep the driver text verbatim.legacy-migration-apply.ts):legacyMarkErroris a byte-faithful port of Go'smarkError— the server position is consumed against UTF-8 byte lengths (Go'slen(line)), the caret line replaces every line after the error line (Go'sappend(lines[:j+1], caret)truncation), and position 0 / past-end / on-a-line-break leave the statement untouched. All semantics were pinned by running Go'smarkErrordirectly on the same inputs. TheDetailline and the SQLSTATE-42704 undefined-type hint block (gated on Go'stypeNamePatternmatch + code42704+ not schema-qualified) are reproduced with Go's exact ordering and indentation.legacyIsSqlStateis hoisted out oflegacy-connect-errors.ts's private pattern so the connect-cause renderer and the exec-error mapper share the server-error discriminator.Behavior notes
exec/queryserver error, not just migration apply — that is the correct owner (Go's session errors all bottom out inPgError.Error()). This incidentally improves the seed path too:failed to send batch: ERROR: … (SQLSTATE …)now matches Go'sSeedFile.ExecBatchWithCachewrap more closely.DatabaseError→@effect/sql-pgSqlErrorchain → the new mapper) so a future@effect/sql-pg/pgbump that changes the error wrapping fails CI instead of silently regressing to the opaque head line.Review pass (architect / engineer / security / DX): all approve. Deliberately left open: terminal-escape passthrough of server-controlled error text is intended Go parity (Go prints the same fields raw to stderr); a
describeLiveDataPlanegolden-path test against a real backend was deemed redundant with the new wire-level test.Fixes CLI-1977
https://linear.app/supabase/issue/CLI-1977/migration-apply-errors-omit-gos-caret-detail-and-42704-extension-hint