-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove UNSPECIFIED aliases for enums with natural zero values #493
Merged
Conversation
This file contains 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
astarche
commented
Jan 28, 2022
reckenro
reviewed
Jan 28, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a few non-attribute enums that still had the allow_alias
and UNSPECIFIED value due to the other 0 value not being directly after it:
- BT
- AcpResultsMeasurementStatus
- PacketType
- Instr
- Boolean
- LinearInterpolationFormat
- Personality
- SelfCalStep
- WLAN
- OfdmLtfSize
- OfdmModAccLSigParityCheckStatus
- OfdmModAccSigBCrcStatus
- OfdmModAccSigCrcStatus
- RFSG
- RoutedSignal
reckenro
reviewed
Jan 28, 2022
mgumble
approved these changes
Jan 28, 2022
reckenro
reviewed
Feb 1, 2022
reckenro
approved these changes
Feb 1, 2022
Co-authored-by: Ryan Eckenrode <[email protected]>
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 does this Pull Request accomplish?
Remove UNSPECIFIED aliases for enums with natural zero values
Fixes #444.
Why should this Pull Request be merged?
Enum aliases make it impossible to map protobuf data back to one-or-the-other specific alias. This specifically causes problems and/or confusion in replay/capture and other grpc-json use cases.
Normally the
UNSPECIFIED
zero-value enum is used as a convention to ensure that the default value of an enum is defined to be invalid/meaningless. This isn't effective when it is aliased to a meaningful zero value from the C API. Also, we use enums along withoneof
s which are a different way of ensuring that a value is set. Ultimately, avoiding aliases is more useful than injecting a conventionalUNSPECIFIED
value that doesn't serve it's intended purpose.Alternatives Considered
Use mapped enum values to avoid valid zero values. The reason we have zero valued enums is because we're using the enum values from the C API, some of which have zero values. Mapped enums provide a way to avoid this. Reason Rejected: This would be massively API breaking for existing drivers and also deviate from the C API. We can consider offering a "mapped" alternative if there is some case where it is especially useful (consider attribute values, which have a lot of overlap), but we should stay-the-course of supporting an API that uses C enum values directly and that solution is sufficient for now.
Breaking change
This change Does not break binary compatibility.
It will break "source compatibility" for existing clients that intentionally use the
UNSPECIFIED
enum value for enums that have a value default value. Those clients will need to make some sort of edit after re-running protoc (Very rare. Either a bug or a test.).What testing has been done?
Ran all RF, Scope, Switch, DCPower, and DAQmx tests. One pre-existing failure.