Implement custom message field defaults#611
Merged
Merged
Conversation
This adds all the deprecation warnings you would ever want, based on the `deprecated` option on most things in Protobuf. This triggers when: 1. Importing a deprecated file. 2. Referencing a deprecated type from another file as a field or method signature type. 3. Using an option whose corresponding field is deprecated. 4. Using a deprecated enum value in an option.
This fixes the bounds check to avoid overflowing the untyped int on 32-bit systems. Overflows on const conversion of `math.MaxUint32`.
…596) This validates that: - `features.utf8_validation` is only used on string fields. - `features.message_encoding` is only used on length-prefixed message fields.
mcy
marked this pull request as ready for review
October 17, 2025 18:52
emcfarlane
approved these changes
Oct 17, 2025
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.
This PR implements the other field pseudo-option,
default.To make this work, I've refactored how pseudo-options are built to be more similar to normal options. Specifically, this is so that the (invalid)
[default.foo = 1]syntax works for message-typed fields.I also added UTF-8 validation of options whose corresponding fields require UTF-8 validation, according to features. Interestingly,
defaultuniquely does not go through this check; in that case, a warning (pointing out that protoc accepts this by mistake) is issued instead.