".head" method can fail. You will have to use "inventoryHistoryLogRepository.versions(nodeId).map( Box(_.headOption) ?~! "No version found for that node, it looks like an unconsistency in storage. Please try again to delete that node")