How can I establish root cause of rejection when empty list is provided

Hello everyone,

I have a question about akka-http logRequestResult directive. I’ve added to it function like below to log on debug successful responses, on info error responses and rejections:

  private def requestBasicInfoAndResponseStatus(req: HttpRequest): RouteResult => Option[LogEntry] = {
    case RouteResult.Complete(res) if res.status.isFailure() => Some(
      LogEntry(s"Request ${req.method} to ${req.uri} resulted in failure with status ${res.status}", Logging.InfoLevel)
    )
    case RouteResult.Complete(res) => Some(
      LogEntry(s"Request ${req.method} to ${req.uri} resulted in response with status ${res.status}", Logging.DebugLevel)
    )
    case RouteResult.Rejected(rejections) => Some(
      LogEntry(s"Request ${req.method} to ${req.uri} was rejected with rejections: $rejections", Logging.InfoLevel)
    )
  }

in logs I see very often

Request HttpMethod(POST/GET/PATCH) to http://URL/PATH was rejected with rejections: List()

I’ve read in docu that empty rejection list could be related to no routing for given path, but that is not the case - provided (path, method) is covered by Route. Is there any way to determine why it happens?

Thanks in advance for any suggestions and help :slight_smile:

Hi,
Is anyone able to help with that? Should I create issue on github repo?

Hi @sebarys,

it sounds like you may be accidentally processing a request even if it hasn’t reached a leaf of the routing tree and actually completed the response. Can you show relevant parts of your routing tree?

If in doubt, move final processing of a request into the complete directive.

Johannes

Hi @jrudolph

For API description we’re using tapir and AkkaHttpServerInterpreter.toRoute(endpoint)(logic)
logic is function Input => Future[Either[Error, Output]] so it shouldn’t be issue with completing request that still processing.