Deserializing of Vertex ID with Custom String value
Hi,
I've come across an issue with deserialization from users enabling custom vertex ID values and types as documented on https://docs.janusgraph.org/advanced-topics/custom-vertex-id/.
Below is a sample GraphSON serialization error highlighting the issue, where a vertex has a custom string ID value (U933779):
The part that confuses me is the RelationIdentifier class as defined in JG 1.0 (https://github.com/JanusGraph/janusgraph/blob/12708188397f69616adddc933e539e841af409e4/janusgraph-driver/src/main/java/org/janusgraph/graphdb/relations/RelationIdentifier.java#L31) still defines the id value as a long.
My question is, for custom vertex id values, what is the correct approach to deserializing ID values? We've tried this with multiple different types of serializers to no avail.
GitHub
janusgraph/janusgraph-driver/src/main/java/org/janusgraph/graphdb/r...
JanusGraph: an open-source, distributed graph database - JanusGraph/janusgraph
Solution:Jump to solution
Hey, turns out it was a mismatch between driver and server version due to the user being on an older version of G.V(), i need to remember to make this the first thing i check 😅
4 Replies
RelationIdentifier::parse
method should be able to parse the given "relationId":"9g3yj-SU933779-8p1"
"9g3yj-SU933779-8p1"
is a vertex property where its internal unique id (a.k.a. relation id, but this name is confusing and overloaded at multiple places so I prefer not to call it relation id) is 9g3yj
(encoded), schema type id is 8p1
(encoded), and vertex id is U933779
.
java.lang.IllegalArgumentException: Invalid id - each token expected to be a number at [Source: (byte[])"{"requestId":"171a7723-7b62-4131-8035-e735ff368ffd","status":{"message":"","code":200,"attributes":{"@type":"g:Map","@value":["host","localhost"]}},"result":{"data":{"@type":"g:List","@value":[{"@type":"g:Vertex","@value":{"id":"U933779","label":"user","properties":{"phone":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"janusgraph:RelationIdentifier","@value":{"relationId":"9g3yj-SU933779-8p1"}},"value":"[REDACTED]","label":"phone","properties":{"metadata":"{}"}}}],"profile"[truncated 645 bytes]; line: 1, column: 415]Did you encounter this with java driver? Do you have a full stacktrace?
Yep, java driver. This was reported to me from a user, ill get this reproduced locally so i can pass on a full stack trace ASAP
turns out having tried it myself that I couldn't reproduce it - I'll get back to the user for more details. In my tests ive just been using the inmemory backend, ill see if i can dig out a stack trace as well
A possibility is the user is using the old version of JanusGraph server (prior to 1.0.0) and G.V is using the new version of JanusGraph driver (1.0.0), or vice versa
Solution
Hey, turns out it was a mismatch between driver and server version due to the user being on an older version of G.V(), i need to remember to make this the first thing i check 😅