-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add unknown field support #775
Comments
I have a feeling that this will come at quite a performance hit. For example, encoders serialize fields in ascending field id order, as of the spec. Making this work with unknown fields might be quite a challenge without hurting performance significantly. We'd probably be better off ignoring order of unknown fields completely, simply appending uninterpreted buffer slices to the final buffer again. |
Yes, implementations for other languages also place unknown fields at the end, so protobuf.js could follow the habit. This should also remove any performance impact, I hope. May be there should anyway be a global option to ignore the unknown fields, in addition to an explicit discard? Does it sound OK that the discardUnknownFields method would be on the decoded data instance (s1/s2 above) or should it rather stay at the type descriptor (Simple_v1/Simple_v2)? |
Yeah, why not.
Instances don't have any methods on them by default (except |
How about #779? I hope the CODECLIMATE_REPO_TOKEN is a problem on the test machine. I had to remove the first variant of writeBytes in writer.js. It looked like a mere optimization, that was however never called and was failing on nodes 4-. It was also ignored by test coverage - that's why the existing tests couldn't find the problem. |
Just wondering about a general opinion, whether the solution looks acceptable as it is or needs any changes? |
Sorry, haven't yet got around to check. Being a bit lazy here because it's not in the official implementation yet, but I appreciate your efforts! |
Fair enough for proto3, if the upcoming specification it's going to define API calls for this feature. This, however, also fulfills the requirement for proto2, that is also handled by protobuf.js. |
I would need this also. Is your PR usable already? |
It's complete and usable, although I'm not using it myself, as dcodeIO may decide to modify it or come up with a different solution. |
I would love to +1 this. Currently, the parse fails with unknown fields in the byte stream. this is a hallmark feature of protobufs in other languages that allows developers to push different applications without breaking. |
It's been a while. Will this change be accepted? |
Protobuf 3 preserves unknown fields by default since release 3.5.0 from 2017-11-13:
This should be a reason to accept pull request #779 or point out what shoul be improved. |
BUMP this is very needed |
This would be very useful feature. Are there any plans to have this implemented or a decision to not implement it? |
@dcodeIO thoughts on what the plan is regarding this feature request? |
@akshah123 Just FYI, we at Google Cloud client libraries will likely need this implemented sooner rather than later, so we'll likely spend some time in December looking into this. |
I added support in my fork. Though it may not be fully spec you can see the
diff here
master...jcgertig:master
…On Mon, Nov 16, 2020 at 11:16 AM Alexander Fenster ***@***.***> wrote:
@akshah123 <https://github.com/akshah123> Just FYI, we at Google Cloud
client libraries will likely need this implemented sooner rather than
later, so we'll likely spend some time in December looking into this.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#775 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADPFOYURHT24MET462V4HDSQFNATANCNFSM4DIZKV7A>
.
|
Anything new here? Is this PR will ever get merged? |
2 similar comments
Anything new here? Is this PR will ever get merged? |
Anything new here? Is this PR will ever get merged? |
protobuf.js version: all, up to the current 6.8.0
proto2 preserve unknown fields for future serialization. This is also planned for proto3 in the near future: https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/edit#heading=h.w8dtggryroj4
I'm working on a merge request that will add unknown fields when decoding as
_unknownFields: { <id|wireType>: }
This should be doable by add read_type_bytes() to Reader and using it instead of skipType. The _unknownField can be later serialized again or discarded by a new method discardUnknownFields().
Tests:
Does it sound OK?
The text was updated successfully, but these errors were encountered: