wolf4ood / gremlin-rs

Gremlin Rust
Apache License 2.0
106 stars 30 forks source link

Error("invalid type: null, expected a UUID string"... when querying #141

Open gudjonragnar opened 3 years ago

gudjonragnar commented 3 years ago

I am trying to use this crate to talk to a gremlin server that is interfacing with an OrientDB graph. When I make simple requests to this gremlin server I get this response (I can provide the full stack trace if necessary):

hread 'test_gremlin_adapter' panicked at 'called `Result::unwrap()` on an `Err` value: Error("invalid type: null, expected a UUID string", line: 1, column: 17)', /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/gremlin-client-0.8.0/src/aio/connection.rs:230:80
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/option.rs:1329:5
   3: core::result::Result<T,E>::unwrap
             at /home/gudjon/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1037:23
   4: gremlin_client::aio::connection::receiver_loop::{{closure}}
             at /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/gremlin-client-0.8.0/src/aio/connection.rs:230:50
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/gudjon/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
   6: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/task/core.rs:147:17
   7: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/loom/std/unsafe_cell.rs:14:9
   8: tokio::runtime::task::core::CoreStage<T>::poll
             at /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/task/core.rs:137:13
   9: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/gudjon/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/task/harness.rs:437:23
  10: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/gudjon/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
  11: std::panicking::try::do_call
             at /home/gudjon/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
...

The setup and query is as follows:

    let options = ConnectionOptions::builder()
            .host(host)
            .port(port)
            .build();
    let client = GremlinClient::connect(options).await?.alias(database)
    let g = traversal().with_remote_async(client);
    let res = g
        .v(())
        .has_label("Entity")
        .has((
            "some-field-here",
            "some-value-here",
        ))
        .values(vec_of_fields)
        .to_list()
        .await
        .expect("Query");

I ran the corresponding query using the gremlin-python library without any trouble, so I know the server is up and responding. Any ideas what could be causing this error?

wolf4ood commented 3 years ago

Hi @gudjonragnar

thanks for raising this issue, let me check it

gudjonragnar commented 3 years ago

Any news on the issue? Would you like any more info?

wolf4ood commented 3 years ago

Hi @gudjonragnar sorry for not getting back to you. It seems related to the serializer version.

By default the driver uses the V3 which should be the same as the OrientDB version. Not sure why it does not work. I got this from the server with your snippet. I will try to check it deeper

deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV2d0.
org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as required. Nested exception: org.apache.tinkerpop.shaded.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.LinkedHashMap` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('aliases')
 at [Source: (byte[])"{"requestId":"94bc074d-8ddc-4914-97aa-2654e9b53996","op":"bytecode","processor":"traversal","args":{"@type":"g:Map","@value":["aliases",{"@type":"g:Map","@value":["g","g"]},"gremlin",{"@type":"g:Bytecode","@value":{"step":[["V"],["hasLabel","Entity"],["has","some-field-here",{"@type":"g:P","@value":{"predicate":"eq","value":"some-value-here"}}]]}}]}}"; line: 1, column: 127]
 at [Source: (byte[])"{"requestId":"94bc074d-8ddc-4914-97aa-2654e9b53996","op":"bytecode","processor":"traversal","args":{"@type":"g:Map","@value":["aliases",{"@type":"g:Map","@value":["g","g"]},"gremlin",{"@type":"g:Bytecode","@value":{"step":[["V"],["hasLabel","Entity"],["has","some-field-here",{"@type":"g:P","@value":{"predicate":"eq","value":"some-value-here"}}]]}}]}}"; line: 1, column: 127] (through reference chain: java.util.LinkedHashMap["args"])
    at org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException.from(JsonMappingException.java:271)
    at org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:1718)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserialize(GraphSONTypeDeserializer.java:194)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserializeTypedFromAny(GraphSONTypeDeserializer.java:101)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.UntypedObjectDeserializer.deserializeWithType(UntypedObjectDeserializer.java:312)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:529)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:364)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:29)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserialize(GraphSONTypeDeserializer.java:212)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserializeTypedFromObject(GraphSONTypeDeserializer.java:86)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.MapDeserializer.deserializeWithType(MapDeserializer.java:400)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:68)
    at org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext.readValue(DeserializationContext.java:760)
    at org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext.readValue(DeserializationContext.java:747)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.AbstractObjectDeserializer.deserialize(AbstractObjectDeserializer.java:48)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserialize(GraphSONTypeDeserializer.java:212)
    at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTypeDeserializer.deserializeTypedFromAny(GraphSONTypeDeserializer.java:101)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer.deserializeWithType(StdDeserializer.java:136)
    at org.apache.tinkerpop.shaded.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:68)
    at org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4014)
    at org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3092)
    at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV2d0.deserializeRequest(AbstractGraphSONMessageSerializerV2d0.java:124)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinBinaryRequestDecoder.decode(WsGremlinBinaryRequestDecoder.java:77)
    at org.apache.tinkerpop.gremlin.server.handler.WsGremlinBinaryRequestDecoder.decode(WsGremlinBinaryRequestDecoder.java:43)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
    at io.netty.handler.codec.http.websocketx.Utf8FrameValidator.channelRead(Utf8FrameValidator.java:82)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at java.lang.Thread.run(Thread.java:748)
criminosis commented 7 months ago

@wolf4ood I'm bumping into this too it seems with 0.8.4. Line number is different from the reporter above but it seems to be the same line of code.

0.8.0

My error:

2024-02-14 10:40:31.921
called Result::unwrap() on an Err value: Error("invalid type: null, expected a string", line: 1, column: 76) 2024-02-14 10:40:31.921 panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/gremlin-client-0.8.6/src/aio/connection.rs:270:80:

0.8.4

I'm working against JG 1.0.0. I think it might be sending back some kind of error code without containing the expected data message, but I'm not sure. Fwiw after the app panics and I restart it, I get along fine for a while and then it panics again so I don't think it's a malformed traversal query, but it seems to occur during high periods of communication (backlog of work running back to back).

criminosis commented 7 months ago

Okay, maybe be a little different. Did a personal fork with some more verbose logging instead of just an unwrap().

It looks like the response comes back with a request_id and a status (500) but then it lacks a message as part of that message and blows up here.

Portion from my fork's error message:

status\":{\"message\":null,

Since this is possible may be worth annotating that field with #[serde(default)]