Tomcat's default max part count is too low in 4.0.x (original) (raw)

Description

When upgrading from Spring Boot 3.5.11 to 4.0.3, a multipart request containing multiple parts starts failing with a 413 Payload Too Large error.

I investigated the issue and found that it can be resolved by configuring the Tomcat limit for the number of parts (e.g., setting server.tomcat.max-part-count). I assume this might be due to a stricter default value introduced in the underlying Tomcat version used by Spring Boot 4.0.x.

I did a text search in the Spring Boot 4.0 Migration Guide but couldn't find any mention of this breaking change or the new default limit. It is possible that it is documented somewhere and I simply missed it. However, if that is the case, it might be a bit difficult for developers to discover.

My Question & Proposal:

I would like to ask if this change in default behavior is a bug, an intentional change, or perhaps an issue with how my test is written?

Steps to Reproduce

I have created a minimal reproducible example repository here:

https://github.com/shayFoo/spring-multi-part

This repository contains two separate folders to demonstrate the difference in behavior:

How to reproduce:

  1. Clone the repository: git clone https://github.com/shayFoo/spring-multi-part.git
  2. Run the test in the demo-multipart-4-0-3 project. You will observe the 413 Payload Too Large error.
  3. Run the test in the demo-multipart-3-5-11 project. You will see it passes without issues.

Expected Behavior

The test in 4.0.3 should pass with a 200 OK status, just like it does in Spring Boot 3.5.11.
If the default multipart limit has intentionally changed in 4.0.x, it should be explicitly and prominently mentioned in the migration guide along with the relevant property (server.tomcat.max-part-count) to configure it.

Actual Behavior

The test fails with a 413 Payload Too Large error in Spring Boot 4.0.3.

Workaround

Explicitly setting server.tomcat.max-part-count in application.properties (or YAML) resolves the issue in 4.0.3.