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

Keeping unknown fields in structs around #42

Open
abhinav opened this issue Jan 15, 2016 · 5 comments
Open

Keeping unknown fields in structs around #42

abhinav opened this issue Jan 15, 2016 · 5 comments

Comments

@abhinav
Copy link
Contributor

abhinav commented Jan 15, 2016

Prashant brought this up in #41: When we run into unknown fields during deserialization, we keep them around in some sort of map and then include them in the serialized result. This would make extension and forwarding use cases possible where you parse the partial argument, act on it somehow, serialize it and forward it elsewhere without losing any information.

CC @kriskowal @prashantv

@prashantv
Copy link
Contributor

There's a feature matrix here for how other serialization libraries handle this:
https://capnproto.org/news/2014-06-17-capnproto-flatbuffers-sbe.html#feature-matrix

Proto2 had it, but removed it in Proto3 (without any justification).

I think it's a good idea to store unknown fields, lets you add fields to semi-opaque structs that are just passed around without having every single hop on the way be updated to understand the struct.

@mjcowan
Copy link

mjcowan commented Oct 6, 2016

This would be a huge help in developer productivity for our team.

@prashantv
Copy link
Contributor

There's more discussion on the removal of uknown fields in proto3 here: protocolbuffers/protobuf#272

There still hasn't been a reason for removal given. I still think we should retail unknown fields.

@mjcowan Can you expand more on your use case and how keeping unknown fields would help your team?

@azylman
Copy link

azylman commented Mar 22, 2017

My team gets objects that have gone through multiple hops, often with little or no modification (e.g. service1 only cares about fieldA, service2 only cares about fieldB, we care about all of them). Right now we just use JSON, but in the future we'd like to define an IDL for the data. If unknown fields weren't kept, then every time we added a new field we might need to update five or six places.

@prashantv
Copy link
Contributor

Just an update, this is now fixed in proto3,
protocolbuffers/protobuf#272

I think we should do something similar to keep them around.

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

No branches or pull requests

4 participants