Skip to content

Add documentations for config to filter internal Druid-related messages from error response - #11755

Merged
maytasm merged 5 commits into
apache:masterfrom
maytasm:IMPLY-10674-2
Oct 1, 2021
Merged

maytasm merged 5 commits into
apache:masterfrom
maytasm:IMPLY-10674-2

Conversation

@maytasm

@maytasm maytasm commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Add documentations for #11711

This PR has:

  • been self-reviewed.
  • 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
  • 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 is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@maytasm maytasm changed the title Add documentations for https://github.com/apache/druid/pull/11711 Add documentations for config to filter internal Druid-related messages from error response (https://github.com/apache/druid/pull/11711) Sep 29, 2021
Comment thread docs/configuration/index.md Outdated
|`druid.indexer.logs.kill.initialDelay`| Optional. Number of milliseconds after Overlord start when first auto kill is run. |random value less than 300000 (5 mins)|
|`druid.indexer.logs.kill.delay`|Optional. Number of milliseconds of delay between successive executions of auto kill run. |21600000 (6 hours)|

### API Error Response

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### API Error Response
### API error response

no caps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated

### API Error Response

Druid API error responses can be configured to hide internal information (such as Druid class name, stack trace, thread name, servlet name, code, line/column number, and host/ip).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Druid API error responses can be configured to hide internal information (such as Druid class name, stack trace, thread name, servlet name, code, line/column number, and host/ip).
You can configure Druid API error responses to hide internal information like the Druid class name, stack trace, thread name, servlet name, code, line/column number, or host/ip.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated

|Property|Description|Default|
|--------|-----------|-------|
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error resulted from the Jetty layer / Jetty filter will have `servlet`, `message`, `url`, `status` and (if exist) `cause` fields in the JSON response. When set to false, the JSON response will only contains `message`, `url`, and `status`. Note that the value of the fields remain unchanged.|true|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error resulted from the Jetty layer / Jetty filter will have `servlet`, `message`, `url`, `status` and (if exist) `cause` fields in the JSON response. When set to false, the JSON response will only contains `message`, `url`, and `status`. Note that the value of the fields remain unchanged.|true|
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error from the Jetty layer / Jetty filter includes `servlet`, `message`, `url`, `status`, and `cause`, if it exists, fields in the JSON response. When set to false, the JSON response only includes `message`, `url`, and `status`. The field values remain unchanged.|true|

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
|Property|Description|Default|
|--------|-----------|-------|
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error resulted from the Jetty layer / Jetty filter will have `servlet`, `message`, `url`, `status` and (if exist) `cause` fields in the JSON response. When set to false, the JSON response will only contains `message`, `url`, and `status`. Note that the value of the fields remain unchanged.|true|
|`druid.server.http.errorResponseTransformStrategy.strategy`|Error response transform strategy to use to transform error response produced within Druid services.|`none`|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`druid.server.http.errorResponseTransformStrategy.strategy`|Error response transform strategy to use to transform error response produced within Druid services.|`none`|
|`druid.server.http.errorResponseTransformStrategy.strategy`|Error response transform strategy. The strategy controls how Druid transforms error responses from Druid services. When empty, Druid leaves error responses unchanged.|`none`|

Is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated

##### Error response transform strategy

Error response transform strategy can be use to transform error response produced within Druid services.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error response transform strategy can be use to transform error response produced within Druid services.
You can use an error response transform strategy to transform error responses from within Druid services to hide internal information.

Suggest re-iterating why you want to use a transform strategy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
Error response transform strategy can be use to transform error response produced within Druid services.
Currently, when error response transform strategy is used (not `none`), the error responses from the following Druid services will be transformed as follow:
- Any query API that failed in the router service. The fields `errorClass` and `host` will always be null while the field `errorMessage` will be transformed based on the set strategy.
- Any SQL qeury API (`/druid/v2/sql/` POST) that failed. The fields `errorClass` and `host` will always be null while the field `errorMessage` will be transformed based on the set strategy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Any SQL qeury API (`/druid/v2/sql/` POST) that failed. The fields `errorClass` and `host` will always be null while the field `errorMessage` will be transformed based on the set strategy.
- For Any SQL query API, for example `POST /druid/v2/sql/...` that fails, Druid sets the fields `errorClass` and `host` to null. Druid applies the transformation strategy to the `errorMessage` field.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated

###### No error response transform strategy

In this mode, error response produced within Druid services are left unchanged and returned to the API client as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this mode, error response produced within Druid services are left unchanged and returned to the API client as is.
In this mode, Druid leaves error responses from underlying services unchanged and returns the unchanged errors to the API client.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
###### No error response transform strategy

In this mode, error response produced within Druid services are left unchanged and returned to the API client as is.
This is the default Druid error response mode. Enable this strategy explicitly by setting druid.server.http.errorResponseTransformStrategy.strategy to none.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is the default Druid error response mode. Enable this strategy explicitly by setting druid.server.http.errorResponseTransformStrategy.strategy to none.
This is the default Druid error response mode. To explicitly enable this strategy, set `druid.server.http.errorResponseTransformStrategy.strategy` to "none".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
Comment on lines +657 to +660
In this mode, the error response produced within Druid services will be validated against a list of regular expressions.
The error message of the response will only be returned to the client if it matches any of the regular expressions configured.
This strategy can be enabled by setting druid.server.http.errorResponseTransformStrategy.strategy=allowedRegex.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this mode, the error response produced within Druid services will be validated against a list of regular expressions.
The error message of the response will only be returned to the client if it matches any of the regular expressions configured.
This strategy can be enabled by setting druid.server.http.errorResponseTransformStrategy.strategy=allowedRegex.
In this mode, Druid validates the error responses from underlying services will against a list of regular expressions. Only error messages that match a configured regular expression are returned. To enable this strategy, set `druid.server.http.errorResponseTransformStrategy.strategy` to `allowedRegex`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit on suggested rewrite (which otherwise lgtm):

...Druid validates the error responses from underlying services will against a list of regular expressions...

should instead be

...Druid validates the error responses from underlying services against a list of regular expressions...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated

|Property|Description|Default|
|--------|-----------|-------|
|`druid.server.http.errorResponseTransformStrategy.allowedRegex`|The list of regular expressions used to check against the error message. If the error message match any of the regular expressions, then it will be included in the response unchanged. If the error message does not match any of the regular expressions then the error message will either be null or replaced with a default message depedning on the type of underlying Exception. |`[]`|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`druid.server.http.errorResponseTransformStrategy.allowedRegex`|The list of regular expressions used to check against the error message. If the error message match any of the regular expressions, then it will be included in the response unchanged. If the error message does not match any of the regular expressions then the error message will either be null or replaced with a default message depedning on the type of underlying Exception. |`[]`|
|`druid.server.http.errorResponseTransformStrategy.allowedRegex`|The list of regular expressions Druid uses to validate error messages. If the error message matches any of the regular expressions, then Druid includes it in the response unchanged. If the error message does not match any of the regular expressions, Druid replaces the error message with null or with a default message depending on the type of underlying Exception. |`[]`|

This could use an example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@clintropolis clintropolis changed the title Add documentations for config to filter internal Druid-related messages from error response (https://github.com/apache/druid/pull/11711) Add documentations for config to filter internal Druid-related messages from error response Sep 30, 2021
Comment thread docs/configuration/index.md Outdated

|Property|Description|Default|
|--------|-----------|-------|
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error from the Jetty layer / Jetty filter includes `servlet`, `message`, `url`, `status`, and `cause`, if it exists, fields in the JSON response. When set to false, the JSON response only includes `message`, `url`, and `status`. The field values remain unchanged.|true|

@techdocsmith techdocsmith Sep 30, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|`druid.server.http.showDetailedJettyErrors`|When set to true, any error from the Jetty layer / Jetty filter includes `servlet`, `message`, `url`, `status`, and `cause`, if it exists, fields in the JSON response. When set to false, the JSON response only includes `message`, `url`, and `status`. The field values remain unchanged.|true|
|`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|

sorry the way I edited this before was a little confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
You can use an error response transform strategy to transform error responses from within Druid services to hide internal information.
When you specify an error response transform strategy other than `none`, Druid transforms the error responses from Druid services as follows:
- For any query API that fails in the Router service, Druid sets the fields `errorClass` and `host` to null. Druid applies the transformation strategy to the `errorMessage` field.
- For Any SQL query API, for example `POST /druid/v2/sql/...` that fails, Druid sets the fields `errorClass` and `host` to null. Druid applies the transformation strategy to the `errorMessage` field.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- For Any SQL query API, for example `POST /druid/v2/sql/...` that fails, Druid sets the fields `errorClass` and `host` to null. Druid applies the transformation strategy to the `errorMessage` field.
- For Any SQL query API that fails, for example `POST /druid/v2/sql/...`, Druid sets the fields `errorClass` and `host` to null. Druid applies the transformation strategy to the `errorMessage` field.

sorry another minor edit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw For Any should be For any?

@techdocsmith techdocsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maytasm thank you for the great example! It really helps. I tweaked some of my previous suggestions and made a couple of suggestions for the wording of the example. Otherwise LGTM.

Comment thread docs/configuration/index.md Outdated
|--------|-----------|-------|
|`druid.server.http.errorResponseTransformStrategy.allowedRegex`|The list of regular expressions Druid uses to validate error messages. If the error message matches any of the regular expressions, then Druid includes it in the response unchanged. If the error message does not match any of the regular expressions, Druid replaces the error message with null or with a default message depending on the type of underlying Exception. |`[]`|

For example, if the original query error response is:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For example, if the original query error response is:
For example, consider the following error response:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
```
{"error":"Plan validation failed","errorMessage":"org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to line 1, column 38: Object 'nonexistent-datasource' not found","errorClass":"org.apache.calcite.tools.ValidationException","host":null}
```
if `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[]` then the query error response will be transformed to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[]` then the query error response will be transformed to
If `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[]`, Druid transforms the query error response to the following:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread docs/configuration/index.md Outdated
```
{"error":"Plan validation failed","errorMessage":null,"errorClass":null,"host":null}
```
however if `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[".*CalciteContextException.*"]` then the query error response will be transformed to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
however if `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[".*CalciteContextException.*"]` then the query error response will be transformed to
On the other hand, if `druid.server.http.errorResponseTransformStrategy.allowedRegex` is set to `[".*CalciteContextException.*"]` then Druid transforms the query error response to the following:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@maytasm
maytasm merged commit 129911a into apache:master Oct 1, 2021
@maytasm
maytasm deleted the IMPLY-10674-2 branch October 1, 2021 10:49
@abhishekagarwal87 abhishekagarwal87 added this to the 0.23.0 milestone May 11, 2022
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
…es from error response (apache#11755)

* add doc

* add doc

* address comments

* fix typo

* address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants