JanusGraph / JanusGraph/janusgraph-dotnet

Unable to specify value for JANUSGRAPH_RELATION_DELIMITER when creating JanusGraphGraphSONMessageSerializer

Open
#216 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
26
Forks
5
PR merge metrics
No merged PRs in 30d

Description

JanusGraph server allows users to specify an environment variable (JANUSGRAPH_RELATION_DELIMITER) to override the default relation delimiter char.
If this is used then the JanusGraphGraphSONMessageSerializer throws an exception when (de)serializing a response that contains relationships.

```
System.ArgumentException: Not a valid relation identifier: odxce:Sfoo-entity-1:mxh:Sfoo-entity-2
at JanusGraph.Net.RelationIdentifier..ctor(String stringRepresentation)
at JanusGraph.Net.IO.GraphSON.RelationIdentifierDeserializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.MapSerializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.ListSerializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONMessageSerializer.DeserializeMessageAsync(Byte[] message, CancellationToken cancellationToken) │
at JanusGraph.Net.IO.GraphSON.JanusGraphGraphSONMessageSerializer.DeserializeMessageAsync(Byte[] message, CancellationToken cancellationToken) │
at Gremlin.Net.Driver.Connection.HandleReceivedAsync(Byte[] received)
at Gremlin.Net.Driver.Connection.ReceiveMessagesAsync()
at Gremlin.Net.Driver.ProxyConnection.SubmitAsync[T](RequestMessage requestMessage, CancellationToken cancellationToken)
at Gremlin.Net.Driver.GremlinClient.SubmitAsync[T](RequestMessage requestMessage, CancellationToken cancellationToken)
```

This can be seen to be caused by the RelationIdentifier class code:

```
private const char ToStringDelimiter = '-';

///
/// Initializes a new instance of the class.
///
/// The underlying relation id.
public RelationIdentifier(string stringRepresentation)
{
StringRepresentation = stringRepresentation;

var elements = stringRepresentation.Split(ToStringDelimiter);
if (elements.Length != 3 && elements.Length != 4)
throw new ArgumentException($"Not a valid relation identifier: {stringRepresentation}");

if (elements[1][0] == LongEncoding.StringEncodingMarker)
{
OutVertexId = elements[1].Substring(1);
}
else
{
OutVertexId = LongEncoding.Decode(elements[1]);
}
TypeId = LongEncoding.Decode(elements[2]);
RelationId = LongEncoding.Decode(elements[0]);
if (elements.Length == 4)
{
if (elements[3][0] == LongEncoding.StringEncodingMarker)
{
InVertexId = elements[3].Substring(1);
}
else
{
InVertexId = LongEncoding.Decode(elements[3]);
}
}
}
```

where the relation delimiter is hard coded to "-"

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the RelationIdentifier(string stringRepresentation) constructor and trace how JanusGraphGraphSONMessageSerializer reaches it while deserializing relationship responses. Reproduce the JANUSGRAPH_RELATION_DELIMITER case and verify that responses using the configured delimiter deserialize without the invalid relation identifier exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.