diff --git a/arangod/Graph/Graph.cpp b/arangod/Graph/Graph.cpp index 04f3919885..400ac85591 100644 --- a/arangod/Graph/Graph.cpp +++ b/arangod/Graph/Graph.cpp @@ -382,6 +382,12 @@ ResultT EdgeDefinition::createFromVelocypack(VPackSlice edgeDefi toSet.emplace(it.copyString()); } + // We do not allow creating an edge definition with either an empty from + // or an empty to set + if (fromSet.size() == 0 || toSet.size() == 0) { + return Result(TRI_ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION); + } + return EdgeDefinition{collection, std::move(fromSet), std::move(toSet)}; } diff --git a/tests/js/common/shell/shell-general-graph.js b/tests/js/common/shell/shell-general-graph.js index 54bf481927..aa53864a05 100644 --- a/tests/js/common/shell/shell-general-graph.js +++ b/tests/js/common/shell/shell-general-graph.js @@ -521,6 +521,33 @@ function GeneralGraphCreationSuite() { assertEqual(g.__edgeDefinitions, []); }, + test_create_WithEmpty_from_to_EdgeDefiniton : function () { + if (db._collection("_graphs").exists(gn)) { + db._collection("_graphs").remove(gn); + } + + // EdgeDefinition with empty from and to array + var edgeDef = graph._edgeDefinitions({ + "collection": "IhaveNoFromsOrTos", + "from": [], + "to": [] + }); + + try { + graph._create( + gn, + edgeDef, + [], + { + numberOfShards: 4, + smartGraphAttribute: "smart" + } + ); + } catch (err) { + assertEqual(err.errorMessage, ERRORS.ERROR_GRAPH_CREATE_MALFORMED_EDGE_DEFINITION.message); + } + }, + test_create_WithOut_Name : function () { if (db._collection("_graphs").exists(gn)) { db._collection("_graphs").remove(gn);