JanusGraph / JanusGraph/janusgraph

GraphMLReader cannot interpret id attribute of node element in GraphML as long value

Open
#1,035 4 comments 0 reactions 0 assignees View on GitHub
kind/enhancement
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

I wanted to load GraphML file with given vertex IDs (the set IDs are in the valid JanusGraph format). A node element in this GraphML file looks like this.
```xml

bar

```

I always get a `IllegalArgumentException` saying `Must provide vertex id`. I investigated the case and figured out that there's some wrong (?) behavior happening when `org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader.findOrCreate(..)` is called while reading the graph and processing a END_ELEMENT for `node` sub-elements (see `org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader.readGraph(..)`:
```java
// ...
} else if (eventType.equals(XMLEvent.END_ELEMENT)) {
final String elementName = reader.getName().getLocalPart();

if (elementName.equals(GraphMLTokens.NODE)) {
final String currentVertexId = vertexId;
final String currentVertexLabel = Optional.ofNullable(vertexLabel).orElse(Vertex.DEFAULT_LABEL);
final Object[] propsAsArray = vertexProps.entrySet().stream().flatMap(e -> Stream.of(e.getKey(), e.getValue())).toArray();

findOrCreate(currentVertexId, graphToWriteTo, vertexFeatures, cache,
true, ElementHelper.upsert(propsAsArray, T.label, currentVertexLabel));
// ...
```

The `currentVertexId` is a String value in the code above which was extracted from the start element's attribute list (respectively the `id` attribute) of the currently processed sub-element. `findOrCreate` expects the vertex ID to be an Object, then. Within `findOrCreate` the passed vertex features are then used to check whether the passed vertex ID is valid which is never the case since the StandardJanusGraph implementation expects the vertex ID to be a `long` value.

Is this a conceptual bug in the StandardJanusGraph implementation? Or is this kind of expected behavior?

Contributor guide

Open the contributing guide

Research direction

Start in org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLReader.readGraph(..), focusing on the END_ELEMENT handling for node and its call to findOrCreate(..). Then inspect how StandardJanusGraph validates vertex IDs and determine whether GraphML string IDs such as "512" should be converted or rejected. Done means the expected behavior is established and the reported incompatibility is resolved or clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.