Required: scala.collection.GenTraversableOnce[?]

The key thing is that, in a for comprehension, all of the types on the right-hand side of the arrows have to be the same, and if I’m understanding it correctly, that’s not the case here.

clonedArticles is a List[ClientArticle]. So when you call

clonedArticles.map(clonedArticle => clientArticleDAO.create(clonedArticle))

you’re winding up with List[Future[yourResponseType]], right? (I’m assuming that create() returns a Future.) That is essentially binding the for comprehension to List, so all of the clauses in it have to be List. But this:

batchDAO.addArticlesToExistingBatch(destinationBatch._id, clonedArticles.map(_._id))

is returning Future[List[ClientArticle]] – a Future, not a List.

So basically, you have to make those line up. I suspect the right answer is to put another Future.sequence around clonedArticles.map(), so that you have Future[List[yourResponseType]]. Once both clauses are Future, it should compile.

(At which point you will need to change the outer map to a flatMap, which suggests that your initial Future.sequence(listFutureClonedArticles) might as well come inside the for, as its first line.)

2 Likes