You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/03/03 18:41:10 UTC
[GitHub] [druid] somu-imply opened a new pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
somu-imply opened a new pull request #12299:
URL: https://github.com/apache/druid/pull/12299
…t in json
Introduced a new config called `druid.server.http.returnJettyErrorsInJson` which by default is set to `true`. When set to true any error from the Jetty layer is returned as a JSON. In case it is set to `false`, the return type is HTML. The following combinations of `druid.server.http.showDetailedJettyErrors` and `druid.server.http.returnJettyErrorsInJson` are tested as in the table below:
druid.server.http.showDetailedJettyErrors | druid.server.http.returnJettyErrorsInJson | Query result
-- | -- | --
false | false | 1curl -X POST http://localhost:8888/druid/v2/sql -H "Content-Type:application/json" -d '{"query": "SELECT COUNT(*) from \""testNumbers\""}' 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> 5<title>Error 500 javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 6 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</title> 7</head> 8<body><h2>HTTP ERROR 500 javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 9 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</h2> 10<table> 11<tr><th>URI:</th><td>/druid/v2/sql</td></tr> 12<tr><th>STATUS:</th><td>500</td></tr> 13<tr><th>MESSAGE:</th><td>javax.servlet.ServletException: com.fasterxml.jackso
n.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 14 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</td></tr> 15</table> 16 17</body> 18</html>
false | true | 1$ curl -X POST http://localhost:8888/druid/v2/sql -H "Content-Type:application/json" -d '{"query": "SELECT COUNT(*) from \""testNumbers\""}' 2{ 3"message":"javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]", 4"url":"/druid/v2/sql", 5"status":"500" 6}
true | false | 1curl -X POST http://localhost:8888/druid/v2/sql -H "Content-Type:application/json" -d '{"query": "SELECT COUNT(*) from \""testNumbers\""}' 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> 5<title>Error 500 javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 6 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</title> 7</head> 8<body><h2>HTTP ERROR 500 javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 9 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</h2> 10<table> 11<tr><th>URI:</th><td>/druid/v2/sql</td></tr> 12<tr><th>STATUS:</th><td>500</td></tr> 13<tr><th>MESSAGE:</th><td>javax.servlet.ServletException: com.fasterxml.jackson
.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 14 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</td></tr> 15<tr><th>SERVLET:</th><td>org.eclipse.jetty.servlet.DefaultServlet-528e5e38</td></tr> 16<tr><th>CAUSED BY:</th><td>javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 17 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</td></tr> 18<tr><th>CAUSED BY:</th><td>com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries 19 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]</td></tr> 20</table> 21<h3>Caused by:</h3><pre>javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character
('t' (code 116)): was expecting comma to separate Object entries 22 at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37] 23 at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:420) 24 at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) 25 at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) 26 at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) 27 at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:286) 28 at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:276) 29 at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:181) 30 at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91) 31 at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120) 32 at com.google.inject.servlet.GuiceFi
lter.doFilter(GuiceFilter.java:135)
true | true | 1$ curl -X POST http://localhost:8888/druid/v2/sql -H "Content-Type:application/json" -d '{"query": "SELECT COUNT(*) from \""testNumbers\""}' 2{ 3"cause1":"com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]", 4"servlet":"org.eclipse.jetty.servlet.DefaultServlet-528e5e38", 5"cause0":"javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37]", 6"message":"javax.servlet.ServletException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('t' (code 116)): was expecting comma to separate Object entries\n at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 37
]", 7"url":"/druid/v2/sql", 8"status":"500" 9}
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #12299:
URL: https://github.com/apache/druid/pull/12299#discussion_r819960008
##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -483,6 +505,28 @@ public boolean isShowServlet()
return false;
}
+
+ @Override
+ public void generateAcceptableResponse(
+ Request baseRequest,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ int code,
+ String message,
+ String contentType
+ ) throws IOException
+ {
+ if (config.isDefaultJettyErrorResponseInJson()) {
+ super.generateAcceptableResponse(baseRequest, request, response, code, message,
+ MimeTypes.Type.APPLICATION_JSON.asString()
+ );
+ } else {
+ super.generateAcceptableResponse(baseRequest, request, response, code, message,
Review comment:
Why are we setting to html here? If this new config is not set, we should still depend on the Accept header to determine the response format right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #12299:
URL: https://github.com/apache/druid/pull/12299#discussion_r819961340
##########
File path: docs/configuration/index.md
##########
@@ -651,7 +651,7 @@ You can configure Druid API error responses to hide internal information like th
|--------|-----------|-------|
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error from the Jetty layer / Jetty filter includes the following fields in the JSON response: `servlet`, `message`, `url`, `status`, and `cause`, if it exists. When set to false, the JSON response only includes `message`, `url`, and `status`. The field values remain unchanged.|true|
|`druid.server.http.errorResponseTransform.strategy`|Error response transform strategy. The strategy controls how Druid transforms error responses from Druid services. When unset or set to `none`, Druid leaves error responses unchanged.|`none`|
-
+|`druid.server.http.returnJettyErrorsInJson`|When set to true, any error from the Jetty layer / Jetty filter is returned as a JSON response. If set to false, the error response is returned as HTML.|false|
Review comment:
I think it will be more extensible and useful for this new config to take in a String to determine the type of response format. For example, "application/json", etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #12299:
URL: https://github.com/apache/druid/pull/12299#discussion_r819960643
##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -483,6 +505,28 @@ public boolean isShowServlet()
return false;
}
+
+ @Override
+ public void generateAcceptableResponse(
+ Request baseRequest,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ int code,
+ String message,
+ String contentType
+ ) throws IOException
+ {
+ if (config.isDefaultJettyErrorResponseInJson()) {
Review comment:
Regardless of what the new config is set to, we should always use the Accept header to determine the response format right? The new config should only apply when the Accept header is not given. This is to maintain backward compatibility with current behavior when this config is not set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #12299:
URL: https://github.com/apache/druid/pull/12299#discussion_r819960643
##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -483,6 +505,28 @@ public boolean isShowServlet()
return false;
}
+
+ @Override
+ public void generateAcceptableResponse(
+ Request baseRequest,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ int code,
+ String message,
+ String contentType
+ ) throws IOException
+ {
+ if (config.isDefaultJettyErrorResponseInJson()) {
Review comment:
Regardless of what the new config is set to, we should always use the Accept header to determine the response format right? The new config should only apply when the Accept header is not given.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] maytasm commented on a change in pull request #12299: Introducing new config to make errors in jetty layer return by defaul…
Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #12299:
URL: https://github.com/apache/druid/pull/12299#discussion_r819962177
##########
File path: server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java
##########
@@ -475,6 +478,25 @@ public void stop()
Lifecycle.Stage.SERVER
);
+ if (config.isDefaultJettyErrorResponseInJson()) {
Review comment:
Nit: Create ErrorHandler (depending on how configs are set outside) of server.setErrorHandler to avoid repeating code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org