diff --git a/arangod/Aql/Functions.cpp b/arangod/Aql/Functions.cpp index 2607e3b3c6..6176c0094a 100644 --- a/arangod/Aql/Functions.cpp +++ b/arangod/Aql/Functions.cpp @@ -3186,8 +3186,10 @@ AqlValue Functions::Shift(arangodb::aql::Query* query, auto iterator = VPackArrayIterator(l); // This jumps over the first element - while (iterator.next()) { + iterator.next(); + while (iterator.valid()) { builder->add(iterator.value()); + iterator.next(); } } builder->close(); diff --git a/arangod/Aql/Graphs.cpp b/arangod/Aql/Graphs.cpp index 6881d353f5..d8cd364ba8 100644 --- a/arangod/Aql/Graphs.cpp +++ b/arangod/Aql/Graphs.cpp @@ -108,14 +108,26 @@ Graph::Graph(VPackSlice const& info) : _vertexColls(), _edgeColls() { for (auto const& def : VPackArrayIterator(edgeDefs)) { TRI_ASSERT(def.isObject()); - std::string eCol = arangodb::basics::VelocyPackHelper::getStringValue( + try { + std::string eCol = arangodb::basics::VelocyPackHelper::getStringValue( def, "collection", ""); - addEdgeCollection(eCol); + addEdgeCollection(eCol); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find 'collection' in the graph definition"); + } // TODO what if graph is not in a valid format any more - VPackSlice tmp = def.get("from"); - insertVertexCollections(tmp); - tmp = def.get("to"); - insertVertexCollections(tmp); + try { + VPackSlice tmp = def.get("from"); + insertVertexCollections(tmp); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find from-collection in the graph definition"); + } + try { + VPackSlice tmp = def.get("to"); + insertVertexCollections(tmp); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find to-collection in the graph definition"); + } } } if (slice.hasKey(_attrOrphans)) {