Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
withSizeLimit causes error 400 instead of 413 #2279
currently (akka http 10.1.5), the withSizeLimit directive returns status 400 (if the request body size exceeds the limit), as specified in https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/misc-directives/withSizeLimit.html.
I think this is a bug because - it should return status code 413, because it is the right status code for that. 400 seems to address errors like syntax errors in the response rather than too big requests (MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400 speaks of syntax errors, the RFC 7231 is not so clear in that case, however there is 413 as status code for that).
The response body of the applied withSizeLimit directive begins with "EntityStreamSizeException: actual entity size (Some......". Wrapping the withSizeLimit directive in a handleExceptions(exceptionHandler) block didn't work for me, the exception handler has not been called.
That seems to be wrong, thanks for checking this! =)
Related to #358. 400 is the 'catch all' code for client errors (the RFC speaks of "something that is perceived to be a client error"), so I don't think this is a bug per se, but I agree using a more specific error code is a useful enhancement.