fix(warehouse): surface actionable error on postgres incremental field type drift - #68293
Closed
posthog[bot] wants to merge 1 commit into
Closed
fix(warehouse): surface actionable error on postgres incremental field type drift#68293posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
…d type drift When a Postgres incremental field's column type is altered after the sync is configured (e.g. a timestamp column changed to text), _build_query still emits a literal of the stored incremental_field_type. Postgres rejects the comparison with "operator does not exist: text > timestamp without time zone", which is classified non-retryable and permanently halts the sync behind a cryptic error with no guidance. Re-validate the persisted incremental field type against the live column type at sync setup and fail early with an actionable message, and map the reactive "operator does not exist" case in get_non_retryable_errors as a fallback. Generated-By: PostHog Code Task-Id: 618e3d05-0467-4122-9417-e0f26713be59
Contributor
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, please remove the |
Contributor
|
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
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.
Problem
A Postgres warehouse source configured for incremental sync on a column whose type
was altered after setup (for example a timestamp column later changed to
text)gets permanently, silently stuck. The stored
incremental_field_typeno longermatches the live column, so
_build_queryemitsWHERE "col" > '<timestamp>'andPostgres rejects it with
operator does not exist: text > timestamp without time zone.Because that message contains
does not exist, it's classified non-retryable and thesync gives up — the customer only sees the raw Postgres error with no guidance on how
to fix it, and the sync stays halted until someone reconfigures the incremental field.
Changes
incremental field type against the live column type (
_validate_incremental_field_type_matches_column).On drift, fail fast with an actionable
IncrementalFieldTypeMismatchErrortelling theuser to reconfigure the incremental field. Compatible cross-type-same-category cases
Postgres handles fine (e.g. a
datecolumn with atimestampcursor) are not flagged;xmin (a synthetic cursor) is excluded.
operator does not existentry toPostgresSource.get_non_retryable_errors, ordered before the genericdoes not existkey so its actionable message wins, as a fallback for any comparison that still reaches
Postgres.
How did you test this code?
Automated tests only (added to
test_postgres.py); no manual sync run was performed.TestValidateIncrementalFieldTypeMatchesColumn— parameterized over compatibletypes (that must not raise, including
date↔timestampandsmallint/bigint↔integer)and incompatible drift (
text/varcharvs a temporal/numeric cursor, cross-categoryswaps), plus the missing-column and xmin skip paths. Catches a regression where drift
detection either fails to fire on a text-vs-timestamp column or false-positives on a
still-compatible column.
TestPostgresSourceNonRetryableErrorsadditions — assert the mismatch (both raw andTemporal-wrapped forms) is non-retryable, and that the
operator does not existkey isordered ahead of
does not existso production'sfriendly_errors[0]surfaces theactionable message rather than
None.Ran the two classes locally: 115 passed.
Automatic notifications
Docs update
🤖 Agent context
Autonomy: Fully autonomous
Authored by Claude Code (Opus 4.8) from a PostHog inbox report. Invoked the
/writing-testsskill before adding tests to apply the value gate (each test groupnames the regression it catches). Considered two approaches from the report — a mapped
user-facing message for the
operator does not existcase, and proactive re-validationat setup — and implemented both: the early validation prevents the mismatched query from
ever reaching Postgres, and the mapped message is a defense-in-depth fallback. Category
grouping (temporal/numeric) was chosen over exact-type equality so legitimate implicit
casts Postgres already accepts (
datevstimestamp) don't get falsely rejected.Created with PostHog Code from an inbox report.