-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
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. What to do if you already signed the CLAIndividual signers
Corporate signers
|
1 similar comment
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. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
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. |
…uffer as discussed in golang#648
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
I am not sure why the following would fail in travis. Any recommendation?
|
proto/table_marshal.go
Outdated
@@ -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()) |
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.
s/Name/String/
reflect.Type.Name
only prints the type name, while reflect.Type.String
provides the package as well.
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.
Thanks for the suggestion.
You can ignore the travis failure. After some digging, it seems that |
Thanks for the change! |
…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.
…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.
…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.
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.
…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.
…uffer as discussed in #648