Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Handling UrlDecodeException in HttpRequestParser and Potential Custom Error Handler Feature

6 views
Skip to first unread message

Andrea Di Cesare

unread,
Nov 21, 2024, 4:50:15 AM11/21/24
to undert...@googlegroups.com

Dear Undertow team,

I am using Undertow with RESTHeart, and I have encountered an issue where certain malformed requests fail during parsing within the io.undertow.server.protocol.http.HttpRequestParser class. 

Specifically, if a query parameter contains an invalid percent-encoded value (e.g., % not followed by two valid hexadecimal characters), Undertow throws a UrlDecodeException, logs the error, and does not proceed to build the HttpServerExchange. Consequently, the request never reaches the handler chain, where RESTHeart would normally manage and log such errors.

Here is an example of the logged message:

10:33:01.044 [XNIO-1 I/O-1] DEBUG io.undertow.request.io - UT005014: Failed to parse request
io.undertow.util.UrlDecodeException: UT000072: Failed to decode url a=%2f&a=1&wrong=%n to charset UTF-8
        at io.undertow.util.URLUtils.decode(URLUtils.java:142)
        at io.undertow.server.protocol.http.HttpRequestParser.decode(HttpRequestParser.java:628)

In this scenario, since the HttpServerExchange is never created, RESTHeart cannot handle the error. To address this, I am looking for a way to either:

  1. Catch and handle these exceptions within Undertow, allowing for custom processing or logging.
  2. Configure a custom error handler in Undertow for such parsing errors, similar to how other exceptions can be handled downstream in the handler chain.

I wanted to ask if there is already a mechanism in place to handle such cases that I might have overlooked. If not, would it be feasible to introduce a feature that allows users to specify an error handler for request parsing failures? This would be particularly useful for propagating these errors to custom logging systems and monitoring solutions.

Thank you for your time and for the excellent work on Undertow. I would greatly appreciate your guidance on how best to address this issue or if such a feature could be considered for future releases.

 Andrea Di Cesare
 Partner at SoftInstigate
 Viale Marconi 29, 65126 Pescara (Italy)
 Skype: ujibang

The company behind RESTHeartThe API Service for the Modern Web with Instant Data APIs on MongoDB, Declarative Access Control and Polyglot Development Framework

Richard Opalka

unread,
Nov 27, 2024, 9:56:14 AM11/27/24
to Undertow Dev
Hello Andrea,

   Please create Undertow issue and mark it as feature request.

Richard
Reply all
Reply to author
Forward
0 new messages