akka-http
akka-http copied to clipboard
Make `toStrictEntity` fail with bad request in case of entity errors
Fixes https://github.com/akka/akka-http/issues/4134
Unsure what exactly to add to the docstring, if anything. Could be something like Fails the route with an [IllegalRequestException] if the request framing is invalid - thoughts?
This rethrows EntityStreamException as IllegalRequestException. This matches more things than the above issue - eg. situations such as exceeding the max entity size. Turns out, exceeding the max entity size also resulted in an internal server error previously and due to this change now results in a bad request - it really ought to be a 413 entity too large, but I can't really distinguish these errors as they currently use the same underlying exception types. But at least 400 Bad Request is better than 500 internal error.
We actually do have an
EntityStreamSizeException- I wonder why we don't throw that one intoStrictinstead of a genericEntityStreamException.
Yeah, I was wondering about that as well. EntityStreamSizeException does not extend EntityStreamException though, and does not have an ErrorInfo so it's fairly different to the exception it currently throws.
We actually do have an
EntityStreamSizeException- I wonder why we don't throw that one intoStrictinstead of a genericEntityStreamException.Yeah, I was wondering about that as well.
EntityStreamSizeExceptiondoes not extendEntityStreamExceptionthough, and does not have anErrorInfoso it's fairly different to the exception it currently throws.
Ah right - so it's useful to use EntityStreamException to get the split between public and private info, and EntityStreamSizeException won't get that until we finish https://github.com/akka/akka-http/pull/3439 . :+1: