Skip to content

proto: revert strict erroring of deterministic and custom marshalers #658

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

Merged
merged 1 commit into from
Jul 27, 2018

Conversation

dsnet
Copy link
Member

@dsnet dsnet commented Jul 24, 2018

PR #650 added strict checking of the use of deterministic with custom marshalers
since it is impossible to know whether a custom marshalers actually do produce
deterministic output or not.

However, this check is breaking hundreds of targets that already rely on
determinism along with custom marshalers. In every case, the custom marshaler
already produced deterministic output, so it did not really matter.

If deterministic is specified and a custom marshaler is not actually
deterministic, then the output is obviously not deterministic,
and setting the flag was a lie. However, there is not much we can do with the
current API. A redesign of the proto API will resolve this tension.

PR #650 added strict checking of the use of deterministic with custom marshalers
since it is impossible to know whether a custom marshalers actually do produce
deterministic output or not.

However, this check is breaking hundreds of targets that already rely on
determinism along with custom marshalers. In every case, the custom marshaler
already produced deterministic output, so it did not really matter.

If deterministic is specified *and* a custom marshaler is not actually
deterministic, then the output is obviously not deterministic,
and setting the flag was a lie. However, there is not much we can do with the
current API. A redesign of the proto API will resolve this tension.
@dsnet dsnet requested a review from neild July 24, 2018 20:49
@dsnet
Copy link
Member Author

dsnet commented Jul 24, 2018

\cc @jmarais @awalterschulze

@dsnet dsnet merged commit 11bd559 into master Jul 27, 2018
@dsnet dsnet deleted the revert-det-check branch July 27, 2018 18:10
@awalterschulze
Copy link

This is very unfortunate.

I don't know what to do for gogoprotobuf to ensure compatibility with golang/protobuf, since we can generate a Marshal method that is either deterministic or not, depending on the extension specified by the user per message.

Another use case: The user with control over a top level Marshal method, might not have control over a 3rd party lower level.

Also when a custom Marshal method is hand coded there is no way to tell if it is deterministic or not or even to tell what the coder intended. If this method had a name like DeterministicMarshal or a deterministic bool parameter, I would be much more comfortable, to defer to user intention, but for now I don't know.

I do get that you had to be pragmatic, but this issue has been a lot of work for us and after much discussion, returning an error was the only solution we could come up with.

@awalterschulze
Copy link

Really you couldn't have punched me in the gut harder than you have just done ;)

@dsnet
Copy link
Member Author

dsnet commented Aug 1, 2018

Really you couldn't have punched me in the gut harder than you have just done ;)

Sorry :(

I don't know what to do for gogoprotobuf to ensure compatibility with golang/protobuf, since we can generate a Marshal method that is either deterministic or not, depending on the extension specified by the user per message.

In this case, I think it's fine for gogo/protobuf and golang/protobuf to diverge in behavior. The situation is unfortunate. When I looked at the failures inside Google, most of the cases of custom Marshalers and Unmarshalers exist because of lack of protobuf reflection. I could spend several weeks cleaning those up hacking around them, or the time could be better spent developing the new reflection APIs.

Furthermore, the interfaces defined in the protoiface package would provide a much more scalable way to specify options and detect support for both golang/protobuf and gogo/protobuf.

I CC'd you on golang/go#26723, where we will be pushing a lot of the reflection code that we have been working on. Personally, I think there's a bright future for Go protobuf interoperability ahead, but there'll be some bumps in the road along the way.

@awalterschulze
Copy link

In this case, I think it's fine for gogo/protobuf and golang/protobuf to diverge in behavior.

Fair enough. I think we have decided the same thing. Although it is not ideal, it is pragmatic.

@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants