Skip to content

Conversation

@Jozott00
Copy link
Collaborator

@Jozott00 Jozott00 commented Feb 9, 2026

Subsystem
Protobuf

Problem Description
Currently, it is not possible to tell the protobuf decoder to discard unknown fields during message parsing.

Solution
This PR adds the ProtobufConfig class that holds the discardUnknownFields property.
If passed to the MessageCodec, it tells the generated protobuf decoder to discard unknown fields.

val protobufConfig = ProtobufConfig(discardUnknownFields = true)
val codec = codec<MyProtoMessage>(protobufConfig)

@Jozott00 Jozott00 self-assigned this Feb 9, 2026
@Jozott00 Jozott00 added the feature New feature or request label Feb 9, 2026
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +117 to +118


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant two nls

* val myCodec = codec<MyMessage>(config)
*
* // Or pass config per-operation
* val decoded = codec.decode(stream, ProtobufConfig(discardUnknownFields = true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be shorter with codec.decode(stream, config) (config is from the line above)

}

encoder.writeMessage(1, firstPart as OtherInternal) { encodeWith(encoder) }
encoder.writeMessage(1, firstPart as OtherInternal) { encodeWith(encoder, null) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the parameter be with a default null value?

Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants