-
Notifications
You must be signed in to change notification settings - Fork 9
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
Handle streaming exceptions as bad requests instead of internal errors #178
base: main
Are you sure you want to change the base?
Handle streaming exceptions as bad requests instead of internal errors #178
Conversation
0eb1106
to
d7b16a8
Compare
@@ -61,7 +60,7 @@ public int read() | |||
|
|||
int i = delegate.read(); | |||
if (i < 0) { | |||
throw new EOFException("Unexpected end of stream"); | |||
throw new AwsProxyStreamException("Unexpected end of stream"); |
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.
Is there an existing AWS SDK Exception we can throw?
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.
There is the SdkServiceException or its subclass AwsServiceException. However I didn't want to use them since I think it might be better to separate the exceptions thrown by the proxy stream classes and handle them differently. Creating this new exception makes it possible to do so without the risk of swallowing other exceptions that might need to be handled differently. wdyt?
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.
Then maybe WebApplicationException
is better. I'm generally against defining bespoke exceptions unless absolutely necessary.
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 think that this class doesn't need to know that this should be handled as a 400 or something else, there is also an issue #73 that aims to separate internal exceptions from the http logic, and throwing a WebApplicationException
here, will not take us closer to addressing that issue.
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.
That's my opinion. I don't think we should be defining new exceptions.
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 agree with Jordan here, creating custom exception classes that don't have extra fields or functions makes the code more convoluted.
This class is part of the proxy's "private" core and is pretty close to networking code, so throwing a WebApplicationException
makes sense
Currently the proxy handles most streaming issues due to mismatch between declared content length and uploaded content length as INTERNAL_ERRORs, except for when it's a STANDARD or W3C_CHUNKED and uploaded > content length, then this is handled as UNAUTHORIZED.
This PR is suggesting handle all of the above as BAD_REQUEST.