Skip to content

Add error logs for HTTP 500 error details #65291

@joshdover

Description

@joshdover

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:

try {
const kibanaResponse = await handler(kibanaRequest, kibanaResponseFactory);
return hapiResponseAdapter.handle(kibanaResponse);
} catch (e) {
this.log.error(e);
return hapiResponseAdapter.toInternalError();
}

Metadata

Metadata

Assignees

Labels

Feature:New PlatformTeam:CorePlatform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t//

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions