natchez-http4s icon indicating copy to clipboard operation
natchez-http4s copied to clipboard

NPE when dealing with a throwable with null message (failed IO)

Open cpellizzari-ledger opened this issue 4 years ago • 0 comments

Hi, thanks for the great work on this lib & others !

Steps to reproduce : fail a traced http route, for instance with IO.raiseError(new RuntimeException)

Expected : no "error.message" mapping, or default to empty string Actual : NullPointerException is raised by Natchez Middleware, as the Circe Encoder fails to encode null value as a string (used with LogTracer).

https://github.com/tpolecat/natchez-http4s/blob/main/modules/http4s/src/main/scala/natchez/http4s/NatchezMiddleware.scala#L62 -> I guess we cannot expect every java + scala codebase with dependencies to always have a message value, and I believe this line should be null checked.

Also in core natchez, a fail-fast null check on put method could be helpful.

cpellizzari-ledger avatar Jan 11 '22 13:01 cpellizzari-ledger