jackson-dataformats-binary icon indicating copy to clipboard operation
jackson-dataformats-binary copied to clipboard

[protobuf] can't parse `reserved` field

Open knoguchi opened this issue 7 years ago • 3 comments

This is a Protoparser problem that it failed to parse reserved field.

Reserved field is explained in the official document. https://developers.google.com/protocol-buffers/docs/proto#reserved

va.lang.IllegalStateException: Syntax error in Unnamed-protobuf-schema at 389:11: unexpected label: reserved

	at com.squareup.protoparser.ProtoParser.unexpected(ProtoParser.java:948)
	at com.squareup.protoparser.ProtoParser.readDeclaration(ProtoParser.java:197)
	at com.squareup.protoparser.ProtoParser.readMessage(ProtoParser.java:219)
	at com.squareup.protoparser.ProtoParser.readDeclaration(ProtoParser.java:153)
	at com.squareup.protoparser.ProtoParser.readProtoFile(ProtoParser.java:92)
	at com.squareup.protoparser.ProtoParser.parse(ProtoParser.java:61)
	at com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader._loadNative(ProtobufSchemaLoader.java:167)
	at com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader._loadNative(ProtobufSchemaLoader.java:161)
	at com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader.loadNative(ProtobufSchemaLoader.java:135)
	at com.fasterxml.jackson.dataformat.protobuf.schema.ProtobufSchemaLoader.load(ProtobufSchemaLoader.java:80)

knoguchi avatar Apr 29 '17 04:04 knoguchi

Do you know if this is a new addition to particular version of protobuf specification?

cowtowncoder avatar Apr 29 '17 19:04 cowtowncoder

I did a bit of research. It seems reserved was added when protobuf v3.0.0-beta was released 2 years ago for both proto2 and proto3 syntax.

The protoc-2.6.1 can't parse the syntax. So it's only available in the protobuf v3.x.x releases. It's a bit confusing but the release version and syntax version is not necessarily corresponding . The proto2 syntax is maintained in the v3 releases.


For now I just commented out the reserved fields. So this is not a big issue.

knoguchi avatar Apr 29 '17 21:04 knoguchi

Ok thank you for checking this out. I was just trying to figure this out since I did not remember seeing this keyword before myself. It seems like a useful thing to have, of course, even with proto v2 as it does not change encoding format. And it is useful for general schema management.

cowtowncoder avatar Apr 30 '17 18:04 cowtowncoder