Skip to content

fix: preserve query string params for multipart requests in Gateway MVC#4162

Open
ar249 wants to merge 1 commit into
spring-cloud:mainfrom
ar249:fix/gateway-mvc-multipart-and-query-string-not-working
Open

fix: preserve query string params for multipart requests in Gateway MVC#4162
ar249 wants to merge 1 commit into
spring-cloud:mainfrom
ar249:fix/gateway-mvc-multipart-and-query-string-not-working

Conversation

@ar249
Copy link
Copy Markdown

@ar249 ar249 commented May 5, 2026

Problem

When a multipart POST request with query string parameters was routed through Spring Cloud Gateway MVC, the query string parameters were silently dropped before reaching the downstream service.

Root cause

StandardMultipartHttpServletRequest merges multipart body parts into the parameter map, overwriting query string parameters in the process.

Solution

Updated the logic inside getParameterMap() in GatewayMultipartHttpServletRequest to decode and return only the query string parameters for gateway requests using MvcUtils.decodeQueryString(), ensuring the multipart body is not parsed and query string params are preserved as-is.

Changes

  • GatewayMultipartHttpServletReques.getParameterMap() — fixed query string decoding logic inside the gateway request guard block

  • GatewayMvcMultipartResolverTest — new test class covering:

    • Multiple distinct query string params are decoded correctly
    • null query string returns an empty map
    • Empty query string returns an empty map
    • Multipart body is not parsed for gateway requests (initializeMultipart() is never called, body fields do not appear in the parameter map)
    • Non-gateway requests delegate to super.getParameterMap()
  • Fixes gateway MVC - Multi-part + query string not working #3220

@ar249 ar249 force-pushed the fix/gateway-mvc-multipart-and-query-string-not-working branch 2 times, most recently from 39b8355 to 9281eb9 Compare May 5, 2026 07:04
Fixes spring-cloudgh-3220

Signed-off-by: Arindam Singh <96876969+ar249@users.noreply.github.com>
@ar249 ar249 force-pushed the fix/gateway-mvc-multipart-and-query-string-not-working branch from 9281eb9 to 9f00e47 Compare May 5, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gateway MVC - Multi-part + query string not working

2 participants