-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
editions: options interpretation can generate incorrect results #16756
Comments
I think this also suffers the issue I pointed out in #16757, where overriding extension 1000 causes some interesting issues. Is there a unique problem here if that's changed to anything else? I suspect there might still be an underlying bug when you use custom features in the same file they're defined in. We've been assuming that's a no-go situation and feature definitions can only change their own values on edition bumps. We could probably lock that down with some extra validation, although the most straight-forward place to put it would be during defaults compilation (which wouldn't stop your example from building) |
Yes, this is the crux of the issue. When interpreting options within a file, the current approach, to partition options into non-extension options and extension options, isn't sufficient. Banning the use of a feature from the file in which it is defined would indeed work, but would be problematic if/when
If it's changed to something else then there is still the issue, similar to the incorrect message encoding, that it would treat the enum as open since it hasn't yet learned that it is closed. So it ends up allowing the |
Yea migrating descriptor.proto to editions has a lot of potential problems (e.g. it can't use language features so it will always be a behavior change), we could always loosen this requirement later if we decide we want to. |
This will prevent users from accidentally overriding these with different types (e.g. protocolbuffers#16757 and protocolbuffers#16756). PiperOrigin-RevId: 631518986
This is an edge case we can't handle properly today. Rather than allowing poorly defined behavior, we'll make this an error condition until we can actually support it. In the future, it may be necessary to upgrade feature files to newer editions. Closes #16756 PiperOrigin-RevId: 634122584
This is an edge case we can't handle properly today. Rather than allowing poorly defined behavior, we'll make this an error condition until we can actually support it. In the future, it may be necessary to upgrade feature files to newer editions. Closes #16756 PiperOrigin-RevId: 634122584
This is an edge case we can't handle properly today. Rather than allowing poorly defined behavior, we'll make this an error condition until we can actually support it. In the future, it may be necessary to upgrade feature files to newer editions. Closes #16756 PiperOrigin-RevId: 634122584
This is an edge case we can't handle properly today. Rather than allowing poorly defined behavior, we'll make this an error condition until we can actually support it. In the future, it may be necessary to upgrade feature files to newer editions. Closes #16756 PiperOrigin-RevId: 634122584
This will prevent users from accidentally overriding these with different types (e.g. protocolbuffers#16757 and protocolbuffers#16756). PiperOrigin-RevId: 633760581
This is an edge case we can't handle properly today. Rather than allowing poorly defined behavior, we'll make this an error condition until we can actually support it. In the future, it may be necessary to upgrade feature files to newer editions. Closes protocolbuffers#16756 PiperOrigin-RevId: 634512378
For Editions, it was necessary to split options interpretation into two steps:
features
is such an option, and they must be interpreted before we can correctly interpret custom options (which may rely on features for correct serialization of those options).Unfortunately, however, because
features
is backed by an extendable message, the above is not adequate. It is still possible to define a source file where the features are not correctly serialized and/or incorrectly validated because they include an extension defined in the same file, whose features themselves have not yet been interpreted:The result of the above is a descriptor set where the
Foo.bar
field has unrecognized fields, because the(custom)
extension is not serialized correctly. It is serialized using normal (length-prefixed) message encoding, though the field has a feature that suggests it should instead be delimited (aka group encoding).As seen in the above output, the
(custom)
feature message is not recognized because it uses incorrect encoding. Here's the relevant portion:Also, a bit surprisingly, the
[another].foo
field has the wrong value:Per closed-enum semantics, I would have expected
foo
to remain unset and there to be an unrecognized value with-321
. Probing a little further, using--decode_raw
, we see that the value was serialized as1
(!!):Super-strange that it serialized the value 1 instead of -321 (which
--decode_raw
would show as 18446744073709551295). (I'll file a separate bug for some pretty strange things I'm seeing in this area.)I don't think there's any trivial way to remedy this. But I think it probably could be handled like so:
Foo
until after the extensions and enums' features are interpreted.Custom.foo
) and complain. By requiring it to be de-structured into multiple option statements, we can successfully process all core features/options first, and then interpret the self-reference after the extension and message's features have been processed.The main case where this would still not work is if the non-extension options/features had their own messy references or even cycles. But that could only happen if
descriptor.proto
were migrated to Editions and it included new options/features that could have this sort of cycle (where they depend on themselves to describe their own features). This is highly unlikely to ever be an issue (though it would be nice if the compiler could at least detect the case, just in case, and complain).The text was updated successfully, but these errors were encountered: