fix(decoderbufs): default op to INSERT for protobufjs 8.2+ compatibility#182
Closed
kibae wants to merge 2 commits into
Closed
fix(decoderbufs): default op to INSERT for protobufjs 8.2+ compatibility#182kibae wants to merge 2 commits into
kibae wants to merge 2 commits into
Conversation
Bumps [protobufjs](https://github.com/protobufjs/protobuf.js) from 8.0.1 to 8.2.0. - [Release notes](https://github.com/protobufjs/protobuf.js/releases) - [Changelog](https://github.com/protobufjs/protobuf.js/blob/master/CHANGELOG.md) - [Commits](protobufjs/protobuf.js@protobufjs-v8.0.1...protobufjs-v8.2.0) --- updated-dependencies: - dependency-name: protobufjs dependency-version: 8.2.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
protobufjs 8.2.0 fixed proto2 enum default behavior: a missing enum field now decodes to the first declared value (UNKNOWN = -1) instead of being implicitly set to 0. Postgres decoderbufs omits the 'op' field for INSERT events, so messages arrived with op=-1 (UNKNOWN) instead of op=0 (INSERT), breaking type detection. Add explicit "default": "INSERT" to the op field so decoderbufs row messages without an op field decode as INSERT, matching the wire-format intent of postgres-decoderbufs.
Owner
Author
|
Closing — this was a workaround for what turned out to be an upstream protobufjs 8.2.0 regression (see #179). The right fix is to wait for an upstream patch rather than papering over it in our proto definition. Will file a protobufjs issue separately. |
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
Upgrading
protobufjsfrom 8.0.x to 8.2.0 (#179) brokedecoder-decoderbufs.spec.ts:Root cause
The Postgres
decoderbufsoutput plugin (the C extension) omits theopfield on the wire for INSERT events to save bytes (the value would be 0, which is the proto3 implicit default).0. We happened to readop === 0and treated it asINSERT.Our enum starts with
UNKNOWN = -1:So after 8.2.0, INSERT events arrive as
op = -1(UNKNOWN) and never matchProtocolBuffersOperation.INSERT.Fix
Add an explicit
"default": "INSERT"to theopfield so messages without anopon the wire decode asINSERT(0). This matches the wire-format intent ofpostgres-decoderbufsand works on both 8.0.x and 8.2.0.Verification
With
protobufjs@8.2.0and PG 17:Related
Unblocks #179 (bump
protobufjsfrom 8.0.1 to 8.2.0).