Skip to content

Adopting Spring Boot Multipart Configuration for File Uploads - #16040

Merged
matrei merged 35 commits into
apache:8.0.xfrom
gsartori:use-spring-upload-config
Sep 20, 2026
Merged

matrei merged 35 commits into
apache:8.0.xfrom
gsartori:use-spring-upload-config

Conversation

@gsartori

Copy link
Copy Markdown
Contributor

Description

Fixes #15644.

This change delegates multipart upload configuration to Spring Boot instead of creating and configuring a Grails-specific MultipartConfigElement.
Applications should now use the standard spring.servlet.multipart properties:

spring:
    servlet:
        multipart:
            max-file-size: 200MB
            max-request-size: 200MB

The previous grails.controllers.upload configuration namespace is no longer supported. If legacy properties are detected, application startup fails with migration instructions instead of silently ignoring them.

The change also:

  • Removes the obsolete upload constants from grails.config.Settings.
  • Removes the corresponding Grails configuration metadata.
  • Allows Spring Boot’s multipart auto-configuration to supply the MultipartConfigElement.
  • Makes servlet registration tolerate multipart support being disabled or otherwise unavailable.
  • Adopts Spring Boot’s defaults of 1 MB per file and 10 MB per multipart request.
  • Adds a regression test covering detection of legacy configuration.
  • Updates the uploading-files documentation and threat model with the new properties and defaults.
    GrailsHibernatePersistentEntity is not changed by these commits.

Contributor Checklist

Issue and Scope

  • This PR is linked to an existing issue that has been acknowledged or approved by the project team: #15644.
  • This PR addresses the complete scope of the linked issue.
  • This PR contains a single, focused change.
  • This PR targets the 8.0.x major release branch, where breaking configuration changes are permitted.

Code Quality

  • I have added or updated tests that cover the changes introduced in this PR.
  • I have verified that all existing tests pass by running ./gradlew build --rerun-tasks.
  • I have run ./gradlew codeStyle and resolved any violations.
  • This PR does not include mass reformatting, style-only changes, or unrelated large-scale refactoring.
  • If generative AI tooling was used, a quality model was used to ensure consistency with the project’s quality standards.

Licensing and Attribution

  • All contributed code is provided under the Apache License 2.0.
  • I have the necessary rights to submit this contribution and confirm it is my own original work.
  • If generative AI tooling was used, I have followed the ASF policy and properly attributed its use.

Documentation

  • The relevant user-facing documentation has been updated.
  • The What’s New section of the Grails Guide has been updated.
  • The Grails 8 Upgrade Notes have been updated to document migration from grails.controllers.upload to spring.servlet.multipart.
  • The PR description clearly explains what was changed and why.

@codecov

codecov Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.1306%. Comparing base (9fdcb77) to head (71737d4).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #16040        +/-   ##
==================================================
+ Coverage     56.1289%   56.1306%   +0.0017%     
- Complexity      21610      21611         +1     
==================================================
  Files            2122       2123         +1     
  Lines          102881     102885         +4     
  Branches        18395      18396         +1     
==================================================
+ Hits            57746      57750         +4     
+ Misses          36889      36888         -1     
- Partials         8246       8247         +1     
Files with missing lines Coverage Δ
.../web/controllers/ControllersAutoConfiguration.java 94.5454% <100.0000%> (+1.4420%) ⬆️
...ers/GrailsControllersEnvironmentPostProcessor.java 100.0000% <100.0000%> (ø)
...core/src/main/groovy/grails/config/Settings.groovy 100.0000% <ø> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gsartori

Copy link
Copy Markdown
Contributor Author

@martei I've added a paragraph in the upgrade guide here as well

@jdaugherty jdaugherty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. I am ok with this but I would like to know if @jamesfredley is ok with this

@jdaugherty

Copy link
Copy Markdown
Contributor

@matrei we merged #16149 - is this PR even needed still? I think we can just close it, yes?

@matrei

matrei commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@matrei we merged #16149 - is this PR even needed still? I think we can just close it, yes?

@jdaugherty No, it is still needed. #16149 changed how an oversized upload fails, not where the limits come from. On 8.0.x today ControllersAutoConfiguration still builds its own MultipartConfigElement from grails.controllers.upload.*, with the 128000-byte defaults, and #15644 (adopt spring.servlet.multipart) is still open. That is exactly what this PR does, and nothing in #16149 overlaps with it.

It does need a rebase though. Two files conflict, and a few things #16149 added now reference the old properties and have to move over with it:

  • ControllersAutoConfiguration.java — the dispatcherServlet bean now takes an Environment for the hidden-method resolution, and the multipartConfigElement bean this PR removes sits right next to it.
  • THREAT_MODEL.md / threat-model.yaml — the upload-limit row now describes ControllersAutoConfiguration overriding Boot's MultipartProperties; it should describe Boot's 1 MB / 10 MB defaults instead.
  • Upgrade guide §53.1 (oversized uploads) and its Undertow note name grails.controllers.upload.maxFileSize / maxRequestSize and the 128000-byte defaults.
  • FileUploadSpec on 8.0.x gained an "upload exceeding the configured limit" test that posts 200000 bytes against the 128000 default. With this PR's app1 config (spring.servlet.multipart.maxRequestSize: 3KB) it still trips the limit, but the given: label should be updated.

@gsartori are you able to rebase, or would you like me to push the rebase onto your branch?

@jamesfredley

Copy link
Copy Markdown
Contributor

This still needs a rebase onto current 8.0.x before it can merge.

Once rebased, please also move the leftover grails.controllers.upload references that landed in #16149:

  • ControllersAutoConfiguration.java — keep the current dispatcherServlet(Environment) / hidden-method wiring; only drop the Grails multipartConfigElement bean and use Boot's MultipartConfigElement via ObjectProvider
  • THREAT_MODEL.md / threat-model.yaml — describe Boot's 1 MB / 10 MB defaults instead of Grails overriding them
  • Upgrade guide oversized-upload notes — point at spring.servlet.multipart instead of grails.controllers.upload and the 128000-byte defaults
  • FileUploadSpec — update the over-limit test's given: label

I approve this after that rebase and cleanup are done. Please squash on merge.

Resolves the conflicts with apache#16149 and moves what that PR added over to
the Spring Boot multipart properties:

- ControllersAutoConfiguration: keep the Environment-aware dispatcherServlet
  bean from apache#16149, drop the Grails MultipartConfigElement bean.
- Upgrade guide §53.1 and its Undertow note now name
  spring.servlet.multipart.* and Boot's 1MB / 10MB defaults, and link to the
  new §4.2 migration section.
- THREAT_MODEL.md keeps the P10 XXE property next to the reworded P9.
- The oversized-upload specs in the app1, app4, jetty and undertow example
  apps relied on the old 128000-byte default. Those apps now configure
  spring.servlet.multipart limits so the 200000-byte payload still trips
  the limit, and the spec labels say so.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@matrei

matrei commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@jamesfredley

I have merged 8.0.x into the branch and resolved the overlap with #16149:

Verified locally: :grails-controllers:test, the four upload-limit integration specs on Tomcat, Jetty and Undertow (26 tests, all green), and aggregateViolations reports no Checkstyle, CodeNarc, PMD or SpotBugs issues.

@matrei matrei moved this from Todo to In Progress in Apache Grails Sep 18, 2026
@matrei
matrei requested a review from sbglasius September 18, 2026 14:50
@matrei
matrei requested a review from dauer September 19, 2026 10:51

@codeconsole codeconsole left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of introducing a GrailsControllersEnvironmentPostProcessor just to maintain a legacy configuration.

This is 8.0.x, let's just get rid of legacy configuration OR deprecate the temporary post processor for removal in 9.0.x. Having the post processor prohibits converting the ControllerAutoConfiguration to pure bean dsl.

The startup check that rejects grails.controllers.upload properties is a
migration aid for applications upgrading from Grails 7, not a permanent
part of the controllers plugin. Mark it for removal and say so in the
upgrade guide.
@testlens-app

testlens-app Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

🚨 All tests passed but jobs failed 🚨

Failed Jobs without Test Failures

❌ CI / Build Grails-Core (macOS JDK 21)

🏷️ Commit: 71737d4
▶️ Tests: 88477 executed
⚪️ Checks: 90/90 completed


Learn more about TestLens at testlens.app/docs.

@matrei

matrei commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@codeconsole Thanks for the review. One clarification first: GrailsControllersEnvironmentPostProcessor does not maintain the legacy configuration. grails.controllers.upload.* is fully removed in this PR (the Settings constants, the configuration metadata and the Grails MultipartConfigElement bean are all gone). The post processor only rejects those properties at startup with migration instructions; nothing is translated or honored.

I would prefer not to drop it outright, for two reasons:

  • Without it the removed properties are silently ignored, and an application that had set, say, maxFileSize: 128000 quietly moves to Boot's 1 MB / 10 MB limits. The upload limits are a security-relevant knob in THREAT_MODEL.md, so a silent loosening on upgrade is the worst way for this to fail.
  • The guard was added at @jdaugherty's request in the earlier review round, as an EnvironmentPostProcessor specifically so the message surfaces before context creation.

So I took your second option: the class is now @Deprecated(forRemoval = true, since = "8.0"), its Javadoc states it is a temporary migration aid that goes away in 9.0 without replacement, and the upgrade guide (§4.2) says the same.

On the bean DSL conversion: the post processor is registered on its own in META-INF/spring.factories and ControllersAutoConfiguration does not reference it, so it should not stand in the way of converting the auto-configuration. If I am missing a coupling there, point me at it and I will sort it out.

@jdaugherty

Copy link
Copy Markdown
Contributor

@codeconsole The post processor won't do anything if you use the correct settings. As Mattias stated this is only a bridge for 8.0.

@codeconsole

Copy link
Copy Markdown
Contributor

@codeconsole The post processor won't do anything if you use the correct settings. As Mattias stated this is only a bridge for 8.0.

That's why I wanted the deprecation tag so we don't forget to remove it.

@matrei
matrei merged commit fc10302 into apache:8.0.x Sep 20, 2026
92 of 93 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Apache Grails Sep 20, 2026
antobinary added a commit to antobinary/bigbluebutton that referenced this pull request Sep 23, 2026
Apache Grails published 8.0.0-RC1 on 2026-09-23. Like M6 before it, the
artifacts are in the ASF staging group only while the release vote runs,
so the TEMP staging-repository entries in build.gradle stay for now and
the comments are retargeted at RC1. Spring Boot stays at 4.1.1 (RC1's BOM
manages the same version); Groovy follows the BOM to 5.1.3 and the
cloud.wondrify asset-pipeline plugin to its 5.2.0-RC1 release, which is
already on Maven Central.

The RC1 Grails Gradle plugin is built against Gradle 9.7
(apache/grails-core#16114): on the 9.6.0 wrapper `gradlew assemble` dies
with NoSuchMethodError on
GroovyCompileOptions.getConfigurationScriptFile() returning a
RegularFileProperty. Move the wrapper to 9.7.1, the current release.

RC1 hands multipart handling to Spring Boot's auto-configuration
(apache/grails-core#16040): the grails.controllers.upload.maxFileSize /
maxRequestSize keys are gone, and an application that still sets them
aborts at startup with a migration message. Move bbb-web's limits to
spring.servlet.multipart.max-file-size / max-request-size with the same
values. Without an explicit setting, Boot's defaults (1 MB per file,
10 MB per request) would silently cap presentation and caption uploads;
BigBlueButton's own per-presentation cap (maxFileSizeUpload, enforced by
ParamsProcessorUtil) is unchanged.

Also in RC1 (apache/grails-core#16149) the _method override moved from a
servlet filter into the dispatcher and is off by default, so the disabled
hiddenHttpMethodFilter registration in resources.groovy is now redundant.
It still compiles and stays inert, so it is left alone here.

Verified with a package build in the grails-8 build image, deployed to a
4.0 dev container: startup in 4.4 s without warnings, checksummed
create/getMeetingInfo/end round-trip, a 5.3 MB presentation upload
through the client (above Boot's default per-file limit), and the api,
learningdashboard, presentation and parameters Playwright suites. Every
remaining failure in those suites reproduces with the same signature on
the pre-upgrade Grails 7.0.12 package (screenshot drift, the @flaky
external-video tests, a test needing maskTagThreshold > 0, and the
predefined breakout groups tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Adopting Spring Boot Multipart Configuration for File Uploads

6 participants