phenopackets / phenopacket-tools

An app and library for building, conversion, and validation of GA4GH Phenopackets.
http://phenopackets.org/phenopacket-tools/stable/
GNU General Public License v3.0
12 stars 5 forks source link

version 1 vs v2 #86

Closed pnrobinson closed 1 year ago

pnrobinson commented 2 years ago

This command

 Phenopacket.parseFrom(jsonString.getBytes());

produces the following if we try to parse a v2 phenopacket

Invalid Phenopacket Message: Protocol message tag had invalid wire type.

This is the expected behavior if we try to unpack the wrong kind of message, but the error message will not be helpful if people are not familiar with protobuf, and also the error message will be the same for any other kind of Message (not just v1 phenopacket). Therefore, it would be good to figure out a way to check if a message is v1 and if so to produce a special error message.

pnrobinson commented 1 year ago

@ielis thoughts?

ielis commented 1 year ago

The users who use low-level protobuf-java have to cope with this scenario. As an alternative, we provide the phenopacket-tools-io module with PhenopacketParser that reads bytes, or an InputStream into a Message and produces more informative error messages.