-
Notifications
You must be signed in to change notification settings - Fork 7
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
Return XML formatted error messages #156
Conversation
f34124d
to
5d4b089
Compare
@ragnard you are probably most familiar with jetty and airlift, any idea why this is happening? This would seem like a jetty bug, but I haven't isolated it to that. |
5d4b089
to
fdadf57
Compare
The Repurposed the PR to add a mapper for any |
67bf1ea
to
ea32780
Compare
.../io/trino/aws/proxy/server/plugin/exception/TestCredentialsProviderExceptionPropagation.java
Outdated
Show resolved
Hide resolved
trino-aws-proxy/src/main/java/io/trino/aws/proxy/server/rest/ErrorResponse.java
Outdated
Show resolved
Hide resolved
trino-aws-proxy/src/main/java/io/trino/aws/proxy/server/rest/ThrowableMapper.java
Outdated
Show resolved
Hide resolved
6e80013
to
342ce27
Compare
342ce27
to
3ab56d1
Compare
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JacksonXmlRootElement(localName = "Error") | ||
public record ErrorResponse(String code, String message, String resource, Optional<String> requestId) | ||
{ } |
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.
Please add compact constructor with notNull checks
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.
Some of them may be null though right? They're being excluded with the @JsonInclude
annotation
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.
True, but since we saw Optional
works I'm in favour of using that and maintaining null safety. We can remove the @JsonInclude
annotation.
We can always come up with values for code
, message
and resource
.
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.
Happy to maintain null safety, but we should then make sure we never construct one of these with a null value. We don't want to have our exception handling logic result in an unhandled exception because of a null check when constructing the response
...proxy/src/test/java/io/trino/aws/proxy/server/credentials/DelegatingCredentialsProvider.java
Outdated
Show resolved
Hide resolved
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.
A few comments
e251b50
to
bd722f5
Compare
ErrorResponse response = new ErrorResponse( | ||
status.reason(), | ||
throwable.getMessage(), | ||
containerRequest.getRequestUri().getPath(), | ||
requestId); |
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.
Should we create a constructor that takes in optionals for all fields and uses a default if the optional is empty?
For instance, if the exception has a null message (which may happen) we'd fail at the requireNonNull
stage and then we lose all the information for the other fields that may be present.
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.
Good point!
I think making all the fields optionals is a bit verbose. The code and resources should always be resolvable (since these are the response status code and the request path), so we can make just the message an optional.
bd722f5
to
ed32f10
Compare
We noticed a regression in our testing suite for internal plugins which seems to be cause by bfbcaf2, specifically the upgrade from
io.airlift:airlift
version249
to266
which bumps the jetty version to12.0.13
.The test added in this PR passed on
io.airlift:airlift
version252
, which would indicate what caused the regression was added in jetty12.0.12
.The root cause is that a
RequestLoggerController
has unclosed sessions when the Airlift Boostrap lifecycle is getting closed.This is because runtime exceptions (that do not inherit from
WebApplicationException
) thrown during request processing (here thrown in the credentials provider plugin, but anywhere works really) causes jetty to not call our response filterRequestFilter#filter(ContainerRequestContext, ContainerResponseContext)
, thus not closing the request logger session.I'm looking into how to fix this regression.