Skip to content
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

Remove stacktrace in response when server throws BadMessageException #379

Conversation

trnguyencflt
Copy link
Member

@trnguyencflt trnguyencflt commented Mar 30, 2023

This will make the response nicer, in term of no stack trace will show up for error on server

  • test to show this works

@trnguyencflt trnguyencflt requested review from a team as code owners March 30, 2023 13:32
Copy link
Member

@AndrewJSchofield AndrewJSchofield left a comment

Choose a reason for hiding this comment

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

I'd like to see a test where the new exception mapper is invoked as a result of a REST call and then demonstrates that there's a JSON response.

@trnguyencflt
Copy link
Member Author

@AndrewJSchofield I'm deploying this to a test cluster and will include the response for a REST request, would that be acceptable?

@AndrewJSchofield
Copy link
Member

@AndrewJSchofield I'm deploying this to a test cluster and will include the response for a REST request, would that be acceptable?

I do see that the effect of this might be to make kafka-rest behave better, so a test in that repo which shows the benefit of this work is acceptable.

@trnguyencflt
Copy link
Member Author

trnguyencflt commented Mar 30, 2023

@AndrewJSchofield thanks for pointing out about kafka-rest, I'm testing this with kafka-rest atm, and it turns out the error is raised at a lower level than application, so using registerExceptionMappers doesn't work.

Will update this PR and raise another PR for kafka-rest once I figure out the correct error handler.

@trnguyencflt trnguyencflt marked this pull request as draft March 31, 2023 08:56
@trnguyencflt trnguyencflt force-pushed the KREST-8335-host-doesnt-match-sni-exception branch from cf38afd to ad3128f Compare March 31, 2023 11:23
@trnguyencflt trnguyencflt changed the title Provide json format for response when the server throw BadMessageException Remove stacktrace when server throws BadMessageException Mar 31, 2023
@trnguyencflt trnguyencflt changed the title Remove stacktrace when server throws BadMessageException Remove stacktrace in response when server throws BadMessageException Mar 31, 2023
@trnguyencflt trnguyencflt force-pushed the KREST-8335-host-doesnt-match-sni-exception branch from ad3128f to 2c8f421 Compare March 31, 2023 15:07
@trnguyencflt trnguyencflt force-pushed the KREST-8335-host-doesnt-match-sni-exception branch from 2c8f421 to 3316f6a Compare April 4, 2023 10:59
@@ -309,10 +308,6 @@ public Handler configureHandler() {
context.setBaseResource(staticResources);
}

if (isErrorStackTraceSuppressionEnabled()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is now moved to Server error handler

@trnguyencflt trnguyencflt marked this pull request as ready for review April 4, 2023 11:53
@trnguyencflt
Copy link
Member Author

@AndrewJSchofield this PR should be ready to review now, I have added tests to validate that it should work (remove stack trace from error response).
Could you please have a look? thanks

Copy link
Member

@AndrewJSchofield AndrewJSchofield left a comment

Choose a reason for hiding this comment

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

lgtm

@trnguyencflt trnguyencflt merged commit da5de82 into confluentinc:master Apr 4, 2023
3 checks passed
@trnguyencflt trnguyencflt deleted the KREST-8335-host-doesnt-match-sni-exception branch April 4, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants