-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: add config to make error messages configurable #4121
feat: add config to make error messages configurable #4121
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stevenpyzhang
I understand the motivation for this, however this introduces a new public API that we'll need to maintain compatibility with (ideally) moving forward. As such, we should consider is this the right interface to expose? . I would say not. I think this needs a little bit more thought.
At the moment the interface allows the actual HTTP status code to be customised, which could result in some strange behaviours if, for example, an implementation returned a success code where an error code was needed. Is there a need to be able to change the status code? I understand from the description its really only the error message we want to customize.
Might we not be better creating a new ErrorMessages
interface or similar, more targeted towards what we actually want to achieve? Such an interface could then be accepted by an Errors
class and used to customise the message in the response.
Let me know if the requirements or your plans cover more than just message text.
Add me back in as a reviewer if you want me to review again.
ksql-rest-app/src/test/java/io/confluent/ksql/rest/server/resources/KsqlResourceTest.java
Outdated
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Outdated
Show resolved
Hide resolved
...c/test/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResourceTest.java
Outdated
Show resolved
Hide resolved
...app/src/test/java/io/confluent/ksql/rest/server/resources/streaming/WSQueryEndpointTest.java
Outdated
Show resolved
Hide resolved
ksql-rest-model/src/main/java/io/confluent/ksql/rest/DefaultErrorsImpl.java
Outdated
Show resolved
Hide resolved
ksql-rest-model/src/main/java/io/confluent/ksql/rest/DefaultErrorsImpl.java
Outdated
Show resolved
Hide resolved
d786b54
to
3bc62ec
Compare
Went with this. The scope for this should be just the error message so I agree, the previous approach was a bit too heavy handed with potentially changing up error codes. |
3bc62ec
to
286a5f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stevenpyzhang
Missing unit tests for the changes to Errors
and the pattern of passing an instance of Errors
to a static method of Errors
is very questionable. Make it a member function!
Otherwise LGTM.
ksql-rest-app/src/main/java/io/confluent/ksql/rest/server/KsqlRestConfig.java
Outdated
Show resolved
Hide resolved
ksql-rest-app/src/main/java/io/confluent/ksql/rest/server/KsqlRestConfig.java
Outdated
Show resolved
Hide resolved
ksql-rest-app/src/main/java/io/confluent/ksql/rest/server/resources/KsqlResource.java
Outdated
Show resolved
Hide resolved
...p/src/main/java/io/confluent/ksql/rest/server/resources/streaming/StreamedQueryResource.java
Outdated
Show resolved
Hide resolved
ksql-rest-app/src/main/java/io/confluent/ksql/rest/util/ErrorResponseUtil.java
Outdated
Show resolved
Hide resolved
ksql-rest-model/src/main/java/io/confluent/ksql/rest/Errors.java
Outdated
Show resolved
Hide resolved
ksql-rest-model/src/main/java/io/confluent/ksql/rest/Errors.java
Outdated
Show resolved
Hide resolved
ksql-rest-model/src/main/java/io/confluent/ksql/rest/Errors.java
Outdated
Show resolved
Hide resolved
return constructAccessDeniedFromKafkaResponse(errorMessages.kafkaAuthorizationErrorMessage(e)); | ||
} | ||
|
||
public String webSocketKafkaAuthorizationErrorMessage(final Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing unit test for this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
this.errorMessages = errorMessages; | ||
} | ||
|
||
public Response accessDeniedFromKafka(final Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing unit test for this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
8d61f2a
to
565fa73
Compare
565fa73
to
2ba7a26
Compare
Description
This PR adds a
ksql.server.error.messages
config which takes a class that implements theErrorMessages
interface. It uses the ErrorMessages class in certain places to return more targeted error messages (such as linking to documentation in the error message when the user runs into ACLs related errors)In the future, more responses can be changed to use methods from the class that's plugged in through the server configs.
Testing done
Unit tests
Made my own ErrorMEssagesImpl and specified it in the config
Reviewer checklist