fix(destination-postgres): re-throw COPY errors and sanitize null bytes in raw JSON - #75902
Merged
Sunil Kuruba (sunil-kuruba) merged 6 commits intoAug 10, 2026
Conversation
…es in raw JSON Previously, PostgresInsertBuffer.flush() caught exceptions during COPY but only logged them, causing syncs to report false success. This fix: 1. Re-throws the exception as SystemErrorException with a descriptive user-facing message identifying the table and error detail. 2. Sanitizes null bytes from JSON-serialized data in raw tables mode, preventing PSQLException for unsupported Unicode escape sequences. Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksPR Slash CommandsAirbyte Maintainers (that's you!) can execute the following slash commands on your PR:
📚 Show Repo GuidanceHelpful Resources
|
Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
|
5 tasks
Contributor
|
Deploy preview for airbyte-docs ready!
Deployed with vercel-action |
Co-authored-by: Claude <noreply@anthropic.com>
Sunil Kuruba (sunil-kuruba)
approved these changes
Aug 10, 2026
Sunil Kuruba (sunil-kuruba)
deleted the
devin/1774972556-fix-postgres-flush-error-message
branch
August 10, 2026 20:35
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.
What
Fixes two bugs in
destination-postgres:flush():PostgresInsertBuffer.flush()caught all exceptions during COPY but only logged them — never re-threw. This caused syncs to report success even when data failed to load into PostgreSQL.PostgresRawRecordFormatterserializes records to JSON for the_airbyte_datacolumn, but did not strip\u0000characters. PostgreSQL TEXT columns reject null bytes, causingPSQLException: unsupported Unicode escape sequence.Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/16126
Related to https://github.com/airbytehq/oncall/issues/11826
How
PostgresInsertBuffer.kt: Replace the log-onlycatchwith a re-throw asSystemErrorException, including the table name and original error message. Thefinallyblock still handles cleanup.PostgresRecordFormatter.kt: Add.replace("\u0000", "")on the JSON-serialized string inPostgresRawRecordFormatter. This complements the existing null byte sanitization inPostgresValueCoercer, which only handles typedStringValuefields (not JSON blobs in raw mode).Review guide
PostgresInsertBuffer.kt— the critical change. Verify the re-throw behavior and that thefinallycleanup block still executes correctly.PostgresRecordFormatter.kt— defensive null byte sanitization for raw tables mode.metadata.yaml/postgres.md— version bump and changelog.Human review checklist:
e.messagecan benullin Kotlin. If so, the user-facing string will contain ". null" at the end. Consider whether this needs a null-safe alternative (e.g.e.message.orEmpty()).User Impact
Can this PR be safely reverted and rolled back?
Link to Devin session: https://app.devin.ai/sessions/32ee87594c6c4fef933ee5adc34eb1e3