-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Labels
Priority:HighPriority Label for high priority issuePriority Label for high priority issuebugSomething isn't workingSomething isn't workingcoresomething about coresomething about coreenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
The implementation that added isolated nodes seems to be assuming that nodeOpt
will always have a value. This is untrue if the node does not exist:
template <typename T>
void Graph<T>::removeNode(const std::string &nodeUserId) {
auto nodeOpt = getNode(nodeUserId);
auto isolatedNodeIt = isolatedNodesSet.find(nodeOpt.value());
...
nodeOpt.value()
is called before verifying the optional has something in it.
This should be updated to something like this:
template <typename T>
void Graph<T>::removeNode(const std::string &nodeUserId) {
auto nodeOpt = getNode(nodeUserId);
auto isolatedNodeIt = isolatedNodesSet.end();
if (nodeOpt) {
isolatedNodeIt = isolatedNodeIt.find(nodeOpt.value());
}
...
The tests should also be updated to test the case where we try to remove a node that does not exist in the graph.
Metadata
Metadata
Assignees
Labels
Priority:HighPriority Label for high priority issuePriority Label for high priority issuebugSomething isn't workingSomething isn't workingcoresomething about coresomething about coreenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers