Gremlin.Net.CosmosDb icon indicating copy to clipboard operation
Gremlin.Net.CosmosDb copied to clipboard

Upstream dependency Gremlin.Net version bump broke CosmosDb

Open veeg opened this issue 5 years ago • 2 comments

Hello.

In PR #44, the upstream dependency of Gremlin.Net was updated from 3.4.0-rc2 to 3.4.0. This release includes TINKERPOP-3067 which changes the returned object from SubmitAsync when the requested return type is JToken. This means that the returned value in not fed through the following GraphSON reader method: https://github.com/apache/tinkerpop/blob/e238880f87bf8366310fdf006d2869c86a2957af/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs#L102-L117

CosmosDb will issue such a request: https://github.com/evo-terren/Gremlin.Net.CosmosDb/blob/94e1fe861aa9d0429b937d41a4a4e0a287d30730/src/Gremlin.Net.CosmosDb/GraphClient.cs#L68-L76

This in turn entails that the return value is not handled properly in CosmosDb, exemplified by the following exception on the sample program:

Unhandled Exception: Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path ''.
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Gremlin.Net.CosmosDb.Serialization.IEdgeJsonConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in /home/veeg/workspace/Gremlin.Net.CosmosDb/src/Gremlin.Net.CosmosDb/Serialization/IEdgeJsonConverter.cs:line 48
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)
   at Gremlin.Net.CosmosDb.Structure.GraphResult`1.<>c__DisplayClass3_0.<.ctor>b__0(JToken token) in /home/veeg/workspace/Gremlin.Net.CosmosDb/src/Gremlin.Net.CosmosDb/Structure/GraphResult.cs:line 91
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Gremlin.Net.CosmosDb.Structure.GraphResult`1..ctor(ResultSet`1 resultSet, JsonSerializer serializer) in /home/veeg/workspace/Gremlin.Net.CosmosDb/src/Gremlin.Net.CosmosDb/Structure/GraphResult.cs:line 91
   at Gremlin.Net.CosmosDb.Structure.GraphResult.ApplyType[T](JsonSerializer serializer) in /home/veeg/workspace/Gremlin.Net.CosmosDb/src/Gremlin.Net.CosmosDb/Structure/GraphResult.cs:line 63
   at Gremlin.Net.CosmosDb.IGraphClientExensions.QueryAsync[T](IGraphClient graphClient, String gremlinQuery, JsonSerializerSettings serializerSettings) in /home/veeg/workspace/Gremlin.Net.CosmosDb/src/Gremlin.Net.CosmosDb/IGraphClient.Extensions.cs:line 153
   at GremlinSample.Program.Main() in /home/veeg/workspace/Gremlin.Net.CosmosDb/GremlinSample/Program.cs:line 42
   at GremlinSample.Program.<Main>()

To summarize what has changed: The JSON returned is now wrapped in an Array, not an Object. This crashes the program.

veeg avatar Mar 28 '19 13:03 veeg

This is a major defect -- the library source in the master branch is currently not usable.

I've created an issue for Gremlin.Net here: https://issues.apache.org/jira/browse/TINKERPOP-2253

SamHard avatar Jul 03 '19 04:07 SamHard

I am also facing this issue.

ankitbko avatar Jul 16 '19 11:07 ankitbko