fix(library-identity-consumer): log error.cause on writer failure so PG diagnostics surface#975
Open
jakebromberg wants to merge 2 commits into
Open
fix(library-identity-consumer): log error.cause on writer failure so PG diagnostics surface#975jakebromberg wants to merge 2 commits into
jakebromberg wants to merge 2 commits into
Conversation
…PG diagnostics surface Drizzle wraps every postgres-js failure in DrizzleQueryError, whose .message is hardcoded to "Failed query: <SQL>\nparams: <params>". The actual PG error (code, detail, constraint_name, column_name) lives on .cause. The orchestrator's catch block only captured (error as Error).message, producing 14,405 identical "Failed query" log lines during the 2026-05-20 first prod run with no PG diagnostic. Surface .cause's standard PostgresError properties on the warn log line so failures are debuggable without a manual psql repro. Field shape mirrors postgres-js's PostgresError (pg_message, pg_code, pg_detail, pg_constraint, pg_column, pg_table, pg_routine).
3 tasks
…message missing - Re-flow the cause type annotation per prettier (CI format:check was failing) - error_message falls back to String(error) for non-Error throws
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why this is independent of the underlying writer_error root cause
Whatever fixes the actual writer failure (TBD; likely a constraint or column-shape issue surfaced by the 2026-05-20 run), the lesson stays: silently swallowing `error.cause` makes any future Drizzle-wrapped DB failure undebuggable from logs alone. This change is observability hygiene, not a behavior change.
Test plan
Followup
This unblocks the diagnosis path on #802's first-run writer failure. Underlying root cause (and a separate fix) tracked separately once the PG error surfaces.