Scala import hell with intellij working with akka-http


Due to security policies we are not allowed to use “underscore” with our imports. Intellij’s scala support is not the best so I had no luck to find the specific import using optional parameters in a http path like:

import akka.http.scaladsl.server.Directives._

  val someRoute: Route = {

    path("path" / "to" / "resource") {
      parameters("color".?) { color =>
       ... do somthing with it

I can trace back the “?” method but not the optional like stated in the documentation:
Anyway finding the specific import was not successful :frowning:

It would be great if someone could help me with this!



optional was only recently introduced, so maybe you just need to use the latest version of Akka HTTP 10.2.0? Both optional and ? are provided by the ParameterDirectives._string2NR implicit conversion.

You can also circumvent explicit imports by using extends Directives or extends ParameterDirectives to get all the necessary symbols in scope (which of course defeats the original purpose of the policy). Optionally you can try to enable wildcard imports in your IDE and only before committing use a refactoring to spell them all out (there’s “Desugar Scala code” in IntelliJ which doesn’t seem to work for me, though?).


Hi Johnnes,

thank you for your hints!

import akka.http.scaladsl.server.directives.ParameterDirectives._string2NR
import akka.http.scaladsl.server.directives.ParameterDirectives.parameters

did the job with akka-http version 10.1.12.

Desugar Scala codes does also not work for me!