1
0
Fork 0

prevent assertion failures when creating smart graphs with invalid options (#8500)

This commit is contained in:
Jan 2019-03-21 16:25:02 +01:00 committed by GitHub
parent 73cf9eb1f3
commit e8f4446c24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -88,7 +88,6 @@ Graph::Graph(velocypack::Slice const& slice)
_rev(basics::VelocyPackHelper::getStringValue(slice, StaticStrings::RevString,
"")) {
// If this happens we have a document without an _key Attribute.
TRI_ASSERT(!_graphName.empty());
if (_graphName.empty()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"Persisted graph is invalid. It does not "
@ -96,13 +95,15 @@ Graph::Graph(velocypack::Slice const& slice)
}
// If this happens we have a document without an _rev Attribute.
TRI_ASSERT(!_rev.empty());
if (_rev.empty()) {
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL,
"Persisted graph is invalid. It does not "
"have a _rev set. Please contact support.");
}
TRI_ASSERT(!_graphName.empty());
TRI_ASSERT(!_rev.empty());
if (slice.hasKey(StaticStrings::GraphEdgeDefinitions)) {
parseEdgeDefinitions(slice.get(StaticStrings::GraphEdgeDefinitions));
}
@ -139,7 +140,6 @@ Graph::Graph(std::string&& graphName, VPackSlice const& info, VPackSlice const&
}
void Graph::parseEdgeDefinitions(VPackSlice edgeDefs) {
TRI_ASSERT(edgeDefs.isArray());
if (!edgeDefs.isArray()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_GRAPH_INVALID_GRAPH,
@ -155,7 +155,11 @@ void Graph::parseEdgeDefinitions(VPackSlice edgeDefs) {
}
void Graph::insertOrphanCollections(VPackSlice const arr) {
TRI_ASSERT(arr.isArray());
if (!arr.isArray()) {
THROW_ARANGO_EXCEPTION_MESSAGE(
TRI_ERROR_GRAPH_INVALID_GRAPH,
"'orphanCollections' are not an array in the graph definition");
}
for (auto const& c : VPackArrayIterator(arr)) {
TRI_ASSERT(c.isString());
validateOrphanCollection(c);