-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error logs for HTTP 500 error details #65291
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
I think this is the key point here. Logging runtime errors / uncatched exceptions thrown from the handler is obviously right, but I'm unsure we should really consider valid responses returned from the handler as actual errors because they got a status >= 400? For example, should all SO routes log an error when they are 'forwarding' a 400 from ES? Second point is, if we do: We don't have any context around the 'error' of a |
@joshdover any update on this? |
I don't know whether such logs provide a lot of value. Let's see how router.get({ path: '/my-plugin/api', validate: ... }, (context, req, res) => {
try {
//...
} catch(e) {
return res.internalError({ body: e.message });
}
}); Note:
In this way, the Kibana server relies on plugins to provide an error message to return res.internalError({...}); factory or log an error message before responding with return res.internalError(); . As the current approach doesn't scale up, I'd suggest we make the body required for the response.internalError factory, even if it touches the code in several plugins., to enforce plugin to provide a meaningful error message.Another alternative could be to make body required, log it automatically, but always respond with generic Internal error occurred. See Kibana logs for details. . As it looks like a bit of magic, so we can recommend plugin not to handle exceptions bubbled to the route handler but rely on the platform to log & handler them instead.
Wee still have 2 other ways to create @elastic/kibana-platform WDYT? |
It seems to be that we should remove
|
Would limiting the allowed type of |
It might be not clear for plugin authors that created |
I've been looking at usages of The cases where the method is called but no error/message is provided are, primarily in the security plugin where they log the error first, and then call
IMHO, they are strong use cases that should be considered when tackling this issue. That said, I agree with you all: 500 errors should behave equally, no matter if they come from throwing errors, How about applying the following changes?
I think that these changes will achieve our goal: log the error and respond What do you think? |
I've created this draft PR with the suggested changes in my previous comment: #85541 |
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:
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 usinglog.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
The text was updated successfully, but these errors were encountered: