Skip to content

no way to access data for unrecognized extensions #385

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

Closed
jhump opened this issue Jun 27, 2017 · 4 comments
Closed

no way to access data for unrecognized extensions #385

jhump opened this issue Jun 27, 2017 · 4 comments

Comments

@jhump
Copy link
Contributor

jhump commented Jun 27, 2017

Access to extensions is provided by top-level functions in the proto package (in extensions.go). But they omit any way to query for the values of unrecognized extensions (as raw unparsed bytes).

My immediate use case is to be able to re-parse custom method options on a descriptor proto using a dynamic extension registry (not limited to just linked-in extensions). This allows a "server browser" tool to show more useful information about a server's exposed services instead of just "unknown fields/extensions". Using the server reflection API, the client can easily ask the server for all known extensions and then re-parse the descriptors (for example, using a dynamic message).

For symmetry with how C++ and Java libraries support extension and unknown fields, it would be preferred for unrecognized extensions to end up in XXX_unrecognized instead of hidden inside of a map of unparsed extension values that is inaccessible. (It used to be accessible via the ExtensionMap() method, but that is no longer generated by protoc-gen-go.)

I also brought this up on the protobuf mailing list, where I think @xfxyjwf expressed a similar sentiment:
https://groups.google.com/d/topic/protobuf/HTNFwKLxtRg/discussion

I believe this could be addressed by merely changing the unmarshalling code to append the data to XXX_unrecognized instead of storing in the map when the looked up *ExtensionDesc is nil.

@jhump
Copy link
Contributor Author

jhump commented Jul 24, 2017

@dsnet any updates on how/when this issue might be resolved?

@jhump
Copy link
Contributor Author

jhump commented Aug 28, 2017

@dsnet, what do you think about #420 as a solution for this? Unlike #386, it has no compatibility issues. Instead, it increases API surface area by one method.

@dsnet
Copy link
Member

dsnet commented Aug 28, 2017

I'll take a look. With Go1.9 out the door, I'm swinging my attention back over to protos.

@dsnet
Copy link
Member

dsnet commented Feb 14, 2018

Closing as fixed with #583. Track #479 for the merging of dev into master.

@dsnet dsnet closed this as completed Feb 14, 2018
@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

No branches or pull requests

2 participants