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

withSizeLimit causes error 400 instead of 413 #2279

Closed
fbe opened this Issue Nov 14, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@fbe
Copy link

fbe commented Nov 14, 2018

Hey there,

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! =)

@raboof

This comment has been minimized.

Copy link
Member

raboof commented Nov 14, 2018

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.

@kstokoz

This comment has been minimized.

Copy link
Contributor

kstokoz commented Nov 14, 2018

Wouldn't it also apply to uri too long which is currently 400 as well - 414 URI Too Long?

@raboof

This comment has been minimized.

Copy link
Member

raboof commented Nov 14, 2018

Sounds reasonable to me! Perhaps add a separate issue for that?

jlprat added a commit that referenced this issue Nov 27, 2018

#2279 Return RequestEntityTooLarge status code in case of EntityStrea…
…mSizeException (#2295)

* #2279 Modify RejectionHandler to complete EntityStreamSizeException with RequestEntityTooLarge status code instead of BadRequest

* #2279 Fix failing test cases in SizeLimitSpec because of update in StatusCode for EntityStreamSizeException case

@jlprat jlprat added this to the 10.1.6 milestone Nov 27, 2018

@jlprat

This comment has been minimized.

Copy link
Member

jlprat commented Nov 27, 2018

Closed by 24fbbf3

@jlprat jlprat closed this Nov 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment