Skip to content
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

Fields are out of order #42

Closed
andyleap opened this issue Mar 25, 2015 · 6 comments
Closed

Fields are out of order #42

andyleap opened this issue Mar 25, 2015 · 6 comments

Comments

@andyleap
Copy link

The generated marshalling code is building messages out of order. While still usable, this doesn't conform to spec.

Issue is most likely at https://github.com/gogo/protobuf/blob/master/plugin/marshalto/marshalto.go#L319, and message.Field just needs to be sorted by tag number

@awalterschulze
Copy link
Member

I must have missed it.
Could you please point to where it says in the spec that the message should be marshaled in field number order?

Do you know what golang/protobuf does?

@EricJ2190
Copy link

@andyleap
Copy link
Author

so, it's not "MUST", just a should, but it shouldn't be too hard. Golang/Protobuf does serialize in tag order https://github.com/golang/protobuf/blob/master/proto/encode.go#L1177

@awalterschulze
Copy link
Member

Awesome thank you for reporting.
This is now an issue that needs to be fixed.
https://developers.google.com/protocol-buffers/docs/encoding#order

@awalterschulze
Copy link
Member

I have made a fix on the proto3 branch
4d206a9
What do you think?

@awalterschulze
Copy link
Member

I believe this is fixed.
Please reopen if you think I am wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants