Replies: 2 comments 5 replies
-
|
I can reproduce, actually just calling |
Beta Was this translation helpful? Give feedback.
-
|
The problem is: However the exception seems like that should not happen. IMHO instead we should always provide an emtpy Cookie attribute to at least avoid this exception. As a workaround for now you could check if def onClientError(request: RequestHeader, statusCode: Int, message: String): Future[Result] = {
// Some client errors happen in a very early stage, when not even Pekko HTTP or Netty can process the request.
// In such cases, from the request no headers (and therefore no cookies) will be parsed - and then
// we will of course also not be able to determine the preferred language of the request.
val messages = request.attrs.get(RequestAttrKey.Cookies).map(_ => messagesApi.preferred(request))
val result = Status(statusCode)(messages.map(_("error.client_error")).getOrElse(message))
Future.successful(result)
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When handling a client error request where characters like
[or]are included in the URI, an unexpected error occurs when usingMessagesApi.Specifically, since the
RequestHeader.attrsdoes not contain theCookiesattribute, accessingRequestHeader.cookiesthrows aNoSuchElementException.Is this expected behavior? Should
RequestHeader.cookiesbe considered unsafe to call in some contexts?Related issue: #8113
It seems to be resolved.
Steps to reproduce:
1. Prepare files:
conf/application.confconf/messageserror.client_error = CLIENT_ERRORapp/ErrorHandler.scala2. Trigger a client error:
$ curl 'localhost:9000/\]' -I HTTP/1.1 500 Internal Server Error Date: Mon, 14 Jul 2025 10:51:54 GMT Connection: close Content-Length: 0Beta Was this translation helpful? Give feedback.
All reactions