Skip to content
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

DataBufferLimitException in WebFlux controllers should result in 413 instead of 500 #32113

Closed
singhbaljit opened this issue Jan 25, 2024 · 2 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@singhbaljit
Copy link
Contributor

When using Spring WebFlux, there is a maximum limit on the payload size, defined by spring.codec.max-in-memory-size (default value is 256KB). If a request is made with a body exceeding this size, DataBufferLimitException is thrown. The default error handler then returns a 500 Internal Server Error response. This is actually not a server side error, but instead a server side validation. This should result in 413 Content Too Large instead.

Spring Boot version: 3.2.1

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 25, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Jan 25, 2024
@bclozel bclozel added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jan 25, 2024
@singhbaljit
Copy link
Contributor Author

singhbaljit commented Jan 25, 2024

Few more thoughts: the error handler probably shouldn't map DataBufferLimitException to 413 directly, as there can be other reasons for the exception. For example, WebClient can also throw this exception, which likely is a server side error. I suppose we should map (i.e. onErrorMap) to another exception that always result in a 413; this should only happen when parsing the body of request. But I'm not very familiar with the spring-framework code, so just guessing.

Also, I do not know if this happens in WebMVC all well; that is a 500 instead of a 413, but it should be straightforward to validate.

@sbrannen sbrannen changed the title DataBufferLimitException in WebFlux controllers should result in 413 instead of 500 DataBufferLimitException in WebFlux controllers should result in 413 instead of 500 Feb 6, 2024
@rstoyanchev rstoyanchev added this to the 6.2.x milestone Feb 6, 2024
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 6, 2024
@bclozel bclozel changed the title DataBufferLimitException in WebFlux controllers should result in 413 instead of 500 DataBufferLimitException in WebFlux controllers should result in 413 instead of 500 Feb 14, 2024
mysend12 added a commit to mysend12/spring-framework-fork that referenced this issue Apr 1, 2024
@snicoll
Copy link
Member

snicoll commented Apr 4, 2024

Closing in favor of PR #32558

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2024
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Apr 4, 2024
@snicoll snicoll removed this from the 6.2.x milestone Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants