Skip to content

Request handler doesn't receive model attributes as built with a build-method #35131

Open
@vermgit

Description

@vermgit

I'm trying to upgrade from Spring-Boot 3.3.13 to 3.4.6 and noticed that there has been a change in how @ModelAttribute or the passing of them in request methods work.

Example request:

/stream/proxy.m3u8?uuid=5aabe0d8-d17b-4212-aabd-acf6eddfb4c0&headers.Origin.0=https%3A%2F%2Fwww.example.com&headers.Referer.0=https%3A%2F%2Fwww.example.com%2F

My code:

  @ModelAttribute("headersFromQuery")
  public HttpHeaders buildHeadersFromQuery(@RequestParam Map<String, String> query) {
    return httpConverterService.buildHeadersFromQuery(query, false);
  }

  @ModelAttribute("cookiesFromQuery")
  public Map<String, String> buildCookiesFromQuery(@RequestParam Map<String, String> query) {
    return httpConverterService.buildCookiesFromQuery(query);
  }

  @GetMapping(path = "/proxy.{mode:.+}", params = { "uuid" })
  public Mono<Void> proxy(@PathVariable String mode, @RequestParam UUID uuid,
      @ModelAttribute("headersFromQuery") HttpHeaders httpHeaders,
      @ModelAttribute("cookiesFromQuery") Map<String, String> cookies,
      @RequestAttribute ProxiedRequestUnit proxiedRequestUnit, ServerHttpResponse serverHttpResponse) {
    return proxy(mode, AbstractPlaylistProvider.getRealUri(uuid), httpHeaders, cookies, proxiedRequestUnit, serverHttpResponse);
  }

With 3.3.13 httpHeaders contained the two entries that came with the request and were dealt with in buildHeadersFromQuery(). With all 3.4.x it seems as if Spring-Boot tries to merge those two entries with the incoming HTTP-headers into httpHeaders. I'm not sure, though, because I can't check the result of this as there is a validation error. With 3.4.6:

	... o.s.w.s.adapter.HttpWebHandlerAdapter    : [2ef1a757-16] HTTP GET "/stream/proxy.m3u8?uuid=5aabe0d8-d17b-4212-aabd-acf6eddfb4c0&headers.Origin.0=https%3A%2F%2Fwww.example.com&headers.Referer.0=https%3A%2F%2Fwww.example.com%2F"
	... s.w.r.r.m.a.RequestMappingHandlerMapping : [2ef1a757-16] Mapped to com.myproject.controller.StreamController#proxy(String, UUID, HttpHeaders, Map, ProxiedRequestUnit, ServerHttpResponse)
	... org.springframework.web.HttpLogging      : [2ef1a757-16] Resolved [WebExchangeBindException: Validation failed for argument at index 2 in method: public reactor.core.publisher.Mono<java.lang.Void> com.myproject.controller.StreamController.proxy(java.lang.String,java.util.UUID,org.springframework.http.HttpHeaders,java.util.Map<java.lang.String, java.lang.String>,com.myproject.service.ProxiedRequestUnit,org.springframework.http.server.reactive.ServerHttpResponse), with 1 error(s): [Field error in object 'headersFromQuery' on field 'acceptLanguage': rejected value [de-AT,de;q=0.9,en-GB;q=0.8,en;q=0.7]; codes [typeMismatch.headersFromQuery.acceptLanguage,typeMismatch.acceptLanguage,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [headersFromQuery.acceptLanguage,acceptLanguage]; arguments []; default message [acceptLanguage]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'acceptLanguage'; Failed to convert from type [java.lang.String] to type [java.util.Locale$LanguageRange] for value [de-AT,de;q=0.9,en-GB;q=0.8,en;q=0.7]]] ] for HTTP GET /stream/proxy.m3u8

In earlier 3.4.x versions it also complained about the "Host"-header.

This is a bug in all 3.4.x as my intention is to use the model attribute as I built it with the build*-methods.

As far as the conversion error is concerned, I don't know what to do with that. It clearly is a normal "Accept-Language"-header, but at this point I don't care about it. It's more important to use the model attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: feedback-providedFeedback has been providedstatus: waiting-for-triageAn issue we've not yet triaged or decided on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions