Skip to content

strict erroring for custom marshalers trying to use a deterministic b… #650

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 2 commits into from
Jul 12, 2018

Conversation

jmarais
Copy link
Contributor

@jmarais jmarais commented Jul 10, 2018

…uffer as discussed in #648

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

1 similar comment
@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@jmarais
Copy link
Contributor Author

jmarais commented Jul 10, 2018

I signed it!

@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@jmarais
Copy link
Contributor Author

jmarais commented Jul 10, 2018

I am not sure why the following would fail in travis. Any recommendation?

go build ./protoc-gen-go/testdata/grpc/grpc.pb.go
# golang.org/x/net/http2
../../../golang.org/x/net/http2/go111.go:10:30: trace.WroteHeaderField undefined (type *clientTrace has no field or method WroteHeaderField)
../../../golang.org/x/net/http2/go111.go:14:26: trace.WroteHeaderField undefined (type *clientTrace has no field or method WroteHeaderField)
../../../golang.org/x/net/http2/go111.go:15:8: trace.WroteHeaderField undefined (type *clientTrace has no field or method WroteHeaderField)

@@ -225,6 +225,9 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
// If the message can marshal itself, let it do it, for compatibility.
// NOTE: This is not efficient.
if u.hasmarshaler {
if deterministic {
return nil, errors.New("proto: deterministic not supported by the Marshal method of " + u.typ.Name())
Copy link
Member

Choose a reason for hiding this comment

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

s/Name/String/

reflect.Type.Name only prints the type name, while reflect.Type.String provides the package as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion.

@dsnet
Copy link
Member

dsnet commented Jul 10, 2018

You can ignore the travis failure. After some digging, it seems that WroteHeaderField was added on June 27th in https://go-review.googlesource.com/c/go/+/67430. However, travis is running with go1.11beta1, which was cut on June 26th, so lacks that function.

@dsnet
Copy link
Member

dsnet commented Jul 12, 2018

Thanks for the change!

@dsnet dsnet merged commit 70b3af3 into golang:master Jul 12, 2018
dsnet added a commit that referenced this pull request Jul 20, 2018
…shalers

PR #650 added a check to error out when a custom marshaler was called and
deterministic marshaling was also specified.

That change performed the check in a relatively obscure location that did not
catch all code paths. Since determinism can only be enabled on the Buffer type,
we check it up front in Buffer.Marshal.

Also, change the test to avoid code injection into generated sources.
dsnet added a commit that referenced this pull request Jul 20, 2018
…shalers

PR #650 added a check to error out when a custom marshaler was called and
deterministic marshaling was also specified.

That change performed the check in a relatively obscure location that did not
catch all code paths. Since determinism can only be enabled on the Buffer type,
we check it up front in Buffer.Marshal.

Also, change the test to avoid code injection into generated sources.
dsnet added a commit that referenced this pull request Jul 20, 2018
…shalers (#656)

PR #650 added a check to error out when a custom marshaler was called and
deterministic marshaling was also specified.

That change performed the check in a relatively obscure location that did not
catch all code paths. Since determinism can only be enabled on the Buffer type,
we check it up front in Buffer.Marshal.

Also, change the test to avoid code injection into generated sources.
dsnet added a commit that referenced this pull request 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.
dsnet added a commit that referenced this pull request Jul 27, 2018
…658)

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.
@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