Skip to content

fix(pgdelta): unmarshal stuckStatements as objects, not strings#5085

Closed
SAY-5 wants to merge 4 commits intosupabase:mainfrom
SAY-5:fix/pgdelta-apply-result-stuck-statements
Closed

fix(pgdelta): unmarshal stuckStatements as objects, not strings#5085
SAY-5 wants to merge 4 commits intosupabase:mainfrom
SAY-5:fix/pgdelta-apply-result-stuck-statements

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 15, 2026

Per #5080, ApplyResult.StuckStatements was typed as []string but pgdelta_declarative_apply.ts emits an array of objects with shape { statement, code, message, isDependencyError }. The mismatch caused json.Unmarshal to fail with:

failed to parse pg-delta apply output: json: cannot unmarshal object
into Go struct field ApplyResult.stuckStatements of type string

This obscured the real underlying error (the pgmq schema not being present in the shadow DB) behind an unrelated parsing failure, and left users with no way to inspect which statements got stuck.

This PR introduces a StuckStatement struct that captures the documented fields, retains the inner statement payload as json.RawMessage so future schema changes don't break parsing, and updates the stderr output to render code + message for each stuck statement instead of dumping a Go-struct repr.

Closes #5080

avallete and others added 4 commits April 14, 2026 07:44
* feat(declarative): add tests for skipping config updates when PgDelta is enabled

- These tests verify that the configuration remains unchanged when PgDelta is enabled, ensuring the declarative directory is the source of truth.
- Updated the WriteDeclarativeSchemas function to reflect the new behavior regarding PgDelta configuration.

* fix(declarative): DSL change due to upgrade
* fix

* test

---------

Co-authored-by: Andrew Valleteau <avallete@users.noreply.github.com>
Per supabase#5080, ApplyResult.StuckStatements was typed as []string but
pgdelta_declarative_apply.ts emits an array of objects with shape
`{ statement, code, message, isDependencyError }`. The mismatch
caused json.Unmarshal to fail with:

  failed to parse pg-delta apply output: json: cannot unmarshal
  object into Go struct field ApplyResult.stuckStatements of type
  string

This obscured the real underlying error (pgmq schema not present in
the shadow DB) behind an unrelated parsing failure.

Introduce a StuckStatement struct that captures the documented
fields, retains the inner statement payload as json.RawMessage so
future schema changes don't break parsing, and updates the stderr
output to render code + message for each stuck statement instead of
dumping a Go-struct repr.

Closes supabase#5080
@SAY-5 SAY-5 requested a review from a team as a code owner April 15, 2026 04:24
@avallete
Copy link
Copy Markdown
Member

Thank's for the contribution, but that should already be taken care of in this PR: #5082

@avallete avallete closed this Apr 15, 2026
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.

4 participants