-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Description
Currently, whenever a 500 error is returned by a handler, there is no default logging of the details of that error. Instead, a generic InternalServerError is logged:
server error [18:42:47.536] Error: Internal Server Error
at HapiResponseAdapter.toError (/home/lizozom/Projects/kibana/src/core/server/http/router/response_adapter.ts:129:19)
at HapiResponseAdapter.toHapiResponse (/home/lizozom/Projects/kibana/src/core/server/http/router/response_adapter.ts:79:19)
at HapiResponseAdapter.handle (/home/lizozom/Projects/kibana/src/core/server/http/router/response_adapter.ts:74:17)
at Router.handle (/home/lizozom/Projects/kibana/src/core/server/http/router/router.ts:264:34)
at process._tickCallback (internal/process/next_tick.js:68:7)
This is different from the behavior of unexpected errors (cases where the handler does not have any try/catch logic that defaults to returning a res.internalError()) which does log the original error using log.error.
We should make this behavior more consistent rather than relying on all plugin HTTP handlers to implement this logging. This would improve the debugging experience for customers & support as well as the developer experience of "where in the world is this error coming from".
Relevant code:
kibana/src/core/server/http/router/router.ts
Lines 261 to 267 in 6a6deef
| try { | |
| const kibanaResponse = await handler(kibanaRequest, kibanaResponseFactory); | |
| return hapiResponseAdapter.handle(kibanaResponse); | |
| } catch (e) { | |
| this.log.error(e); | |
| return hapiResponseAdapter.toInternalError(); | |
| } |