aws / graph-explorer

React-based web application that enables users to visualize both property graph and RDF data and explore connections between data without having to write graph queries.
https://github.com/aws/graph-explorer
Apache License 2.0
328 stars 48 forks source link

[Bug] Unable to create a connection successfully if a graph databases contains only vertices and no edges #99

Closed joywa closed 4 months ago

joywa commented 1 year ago

Community Note

Describe the bug

Tested this with Neptune db. I created vertices on the db with no edges in gremlin format. Then trying to create connection from graph-explorer, the connection was not successful. Misleading error gives as unable to connect with database but while debugging the backend error is:

{
code: 'MalformedQueryException',
detailedMessage: "Failed to interpret Gremlin query: Query parsing failed at line 1, character position at 14, error message : no viable alternative at input 'g.E().project()'",
requestId: '3b949d91-2969-4602-9aee-ec1d6e363eed'
}

Expected behavior There should be a clear error from the UI as to what is happening. Also this should not fail a connection as nodes can still be displayed without edges on Graph Explorer.

Currently errors like above are not logged visibly in the proxy code. Hence needs debugging to find the actual errors. I would recommend checking the response code and log the errors on the console.

krlawrence commented 1 year ago

Just a comment that g.E().project() is not valid Gremlin either. The Graph Explorer code should check the edge count and if it is zero not try to enumerate the edges. We also need to look at why invalid Gremlin is being generated by the Explorer in this case. It's quite possible that the lack of edges not being caught is the root cause.

kmcginnes commented 4 months ago

I attempted to reproduce this issue, but could not.

I also looked at the code and it seems like there are protections against this happening.

https://github.com/aws/graph-explorer/blob/c8bb106ffae6c75893f02520f3cd4cce87ab2349/packages/graph-explorer/src/connector/gremlin/queries/fetchSchema.ts#L183-L185

This must've been an issue from long enough ago where there sync process could somehow reach this state. But from what I can see, this bug has been fixed.