Problem
Your for gets desugared in:
authHeaders.flatMap(headers => headers.map(header => header -> header))
The problem in this case is to use flatMap because authHeaders is Option .
Let's look at the signature. ( http://www.scala-lang.org/api/2.11.1/index.html#scala.Option )
final def flatMap[B](f: (A) β Option[B]): Option[B]
So, the function f is expected to return Option . But authHeaders.map(header => header -> header) not Option , and therefore you get an error.
Decision
Assuming that if authHeaders is None , you need an empty Map , we can use fold .
authHeaders.fold(Map.empty[String, String])(_.map(s => s -> s).toMap)
The first parameter is the result if authHeaders is None . The second is expected to be a Set[String] => Map[String, String] function and will be evaluated if there is some Set .
If you want to store the result in Option and just want to have a Map when there are actually several Set , you can just use Map .
authHeaders.map(_.map(s => s -> s).toMap)
Regarding your extra note
This is the signature of flatMap on TraversableOnce . ( http://www.scala-lang.org/api/2.11.1/index.html#scala.collection.TraversableOnce )
def flatMap[B](f: (A) β GenTraversableOnce[B]): TraversableOnce[B]
Here f can return any collection that is an instance of GenTraversableOnce .
So, such things are possible: Set(1,2,3).flatMap(i => List(i)) (not a very creative example, I know ..)
I see Option as a special case.