LukeMathWalker/tracing-actix-web

Log malformed request

SuperFluffy opened this issue · 4 comments

Is there a way to trace a malformed request back to a handler's extractor?

Case in point: I am using a frontend library that tries sending Content-Type: multipart/form-data, whereas the handler is defined with an extractor data: Json<T>, so expects Content-Type: application/json. The result is that actix (or rather, tracing-actix-web) immediately responds with an error message like so:

{
"v":0,
"name":"myserver",
"msg":"[REQUEST - END]",
"level":30, "hostname":"blackie",
"pid":317513,
"time":"2021-05-26T12:26:42.608467885+00:00",
"target":"tracing_actix_web",
"line":136,
"file":"/home/janis/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-actix-web-0.2.1/src/lib.rs",
"user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
"request_path":"/api/file/upload",
"request_id":"26f87728-6480-4530-ab2f-ceeb0d883171",
"status_code":400,
"elapsed_milliseconds":3,
"client_ip_address":"127.0.0.1:56614"
}

The only indication I have that something is wrong is status_code: 400, but it's really hard to figure out that it was the extractor that was unhappy about the request.

Have you tried using the latest beta version? It has enhanced error logging, capturing many more info than 0.2.x did.

I haven't yet! I am still on actix 3.*. I'll update and report back.

Can I close this one @SuperFluffy?

I haven't gotten around to checking this. Sorry. :( Can be closed. If this pops up again, I will reopen.