-
Couldn't load subscription status.
- Fork 2.8k
[ZEPPELIN-6356] Fix ZeppelinClientIntegrationTest #5097
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
Conversation
|
@Reamer When you have a moment, could you please take a look at this? |
- Introduced `ConflictException` for detailed error response. - Added handling of `NotePathAlreadyExistsException` in `NotebookRestApi`.
13cc043 to
aa0c2e2
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.
I thought long and hard about how to solve this problem.
There are various exceptions in org.apache.zeppelin.rest.exception that inherit from WebApplicationException, and there are mappings in the code in various places. In my opinion, this is somewhat unnecessary, as we have an ExceptionMapper. It currently has an unattractive name, WebApplicationExceptionMapper, but it is a mapper for exceptions from the code to return a response.
I would rather solve the problem this way.
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/WebApplicationExceptionMapper.java
@@ -22,18 +22,22 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
+import org.apache.zeppelin.notebook.exception.NotePathAlreadyExistsException;
+import org.apache.zeppelin.utils.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Provider
public class WebApplicationExceptionMapper implements ExceptionMapper<Throwable> {
-
+
private static final Logger LOGGER = LoggerFactory.getLogger(WebApplicationExceptionMapper.class);
@Override
public Response toResponse(Throwable exception) {
if (exception instanceof WebApplicationException) {
return ((WebApplicationException) exception).getResponse();
+ } else if (exception instanceof NotePathAlreadyExistsException) {
+ return ExceptionUtils.jsonResponseContent(Response.Status.CONFLICT, exception.getMessage());
} else {
LOGGER.error("Error response", exception);
// Return generic error message to prevent information disclosure
zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
Outdated
Show resolved
Hide resolved
b07f794 to
69ebbf1
Compare
69ebbf1 to
9a5cabf
Compare
|
Understood. So you prefer letting exceptions be thrown at the source and then handling them centrally in |
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.
All that's missing is the removal of an unnecessary class, otherwise it looks good to me. This change is, of course, a breaking change and will therefore only be merged into the master.
zeppelin-server/src/main/java/org/apache/zeppelin/rest/exception/ConflictException.java
Outdated
Show resolved
Hide resolved
Yes, I hope this simplifies the code and leads to a uniform API response. |
|
@Reamer I removed that class. I also realized I merged the previous PR, which caused the test failure, into |
|
I noticed the tests aren't fixed yet. I'll correct them and re-request review. Sorry for the confusion. |
No, that's not necessary. We'll merge this change as well and accept the breaking change. |
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.
LGTM
### What is this PR for? After #5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists. This PR introduces a `ConflictException` and updates `NotebookRestApi` to return HTTP 409 (Conflict) when `NotebookService` throws or returns `NotePathAlreadyExistsException`. I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because `NotebookService` is also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer. ### What type of PR is it? Bug Fix ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6356 ### How should this be tested? - Check if `zeppelin-integration-test` and other tests pass ### Screenshots (if appropriate) <img width="1609" height="100" alt="image" src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964" /> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5097 from tbonelee/fix-client-integration-test. Signed-off-by: ChanHo Lee <[email protected]> (cherry picked from commit 33f35dc) Signed-off-by: ChanHo Lee <[email protected]>
|
Thansk, I merged this into master and also the branch-0.12 as you suggested |
### What is this PR for? After apache#5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists. This PR introduces a `ConflictException` and updates `NotebookRestApi` to return HTTP 409 (Conflict) when `NotebookService` throws or returns `NotePathAlreadyExistsException`. I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because `NotebookService` is also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer. ### What type of PR is it? Bug Fix ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6356 ### How should this be tested? - Check if `zeppelin-integration-test` and other tests pass ### Screenshots (if appropriate) <img width="1609" height="100" alt="image" src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964" /> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes apache#5097 from tbonelee/fix-client-integration-test. Signed-off-by: ChanHo Lee <[email protected]>
### What is this PR for? After apache#5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists. This PR introduces a `ConflictException` and updates `NotebookRestApi` to return HTTP 409 (Conflict) when `NotebookService` throws or returns `NotePathAlreadyExistsException`. I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because `NotebookService` is also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer. ### What type of PR is it? Bug Fix ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6356 ### How should this be tested? - Check if `zeppelin-integration-test` and other tests pass ### Screenshots (if appropriate) <img width="1609" height="100" alt="image" src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964" /> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes apache#5097 from tbonelee/fix-client-integration-test. Signed-off-by: ChanHo Lee <[email protected]>
### What is this PR for? After apache#5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists. This PR introduces a `ConflictException` and updates `NotebookRestApi` to return HTTP 409 (Conflict) when `NotebookService` throws or returns `NotePathAlreadyExistsException`. I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because `NotebookService` is also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer. ### What type of PR is it? Bug Fix ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6356 ### How should this be tested? - Check if `zeppelin-integration-test` and other tests pass ### Screenshots (if appropriate) <img width="1609" height="100" alt="image" src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964" /> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes apache#5097 from tbonelee/fix-client-integration-test. Signed-off-by: ChanHo Lee <[email protected]>
### What is this PR for? After apache#5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists. This PR introduces a `ConflictException` and updates `NotebookRestApi` to return HTTP 409 (Conflict) when `NotebookService` throws or returns `NotePathAlreadyExistsException`. I chose to do this exception-to-HTTP mapping in `NotebookRestApi` because `NotebookService` is also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer. ### What type of PR is it? Bug Fix ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-6356 ### How should this be tested? - Check if `zeppelin-integration-test` and other tests pass ### Screenshots (if appropriate) <img width="1609" height="100" alt="image" src="https://github.com/user-attachments/assets/a445f36c-0267-42df-a75e-9f9f05f94964" /> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes apache#5097 from tbonelee/fix-client-integration-test. Signed-off-by: ChanHo Lee <[email protected]>
What is this PR for?
After #5090, we started hiding unhandled error details from clients, which caused some tests that depended on those details to fail. The afffected cases are note imports/creations that should fail when the target note path already exists.
This PR introduces a
ConflictExceptionand updatesNotebookRestApito return HTTP 409 (Conflict) whenNotebookServicethrows or returnsNotePathAlreadyExistsException.I chose to do this exception-to-HTTP mapping in
NotebookRestApibecauseNotebookServiceis also used outside REST contexts, and assigning HTTP status codes belongs in the REST layer.What type of PR is it?
Bug Fix
What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-6356
How should this be tested?
zeppelin-integration-testand other tests passScreenshots (if appropriate)
Questions: