affect:6+

Comment From: snicoll

@thomajic an issue report with only a title is not actionable. If you want us to investigate, please describe the problem you're facing, and in which version this was working. Attaching a sample we can run ourselves would significantly increase the likelihood of a speedy response.

Comment From: thomajic

    @GetMapping
    public MyModel exampleMethod(@ModelAttribute("myModel") MyModel model,
      BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            // Method logic
            return model;
        }
      return model;
    }

I am using basic code

for converter i am using conversionservice

@AutoConfiguration
public class WebDataBinderConfig implements WebMvcConfigurer {

  @Override
  public void addFormatters(FormatterRegistry registry) {
    registry.addConverter(new CustomStringToSetConverter());
    registry.addConverter(String.class, Instant.class, Instant::parse);

    registry.removeConvertible(String.class, Collection.class);
  }
}

I am using java21 and springboot 3.2.1

I am getting below error

Failed to convert property value of type 'java.lang.String' to required type 'java.time.Instant' for property 'date'; Cannot convert value of type 'java.lang.String' to required type 'java.time.Instant' for property 'date': no matching editors or conversion strategy found\n\tat org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:135)\n\tat com.adidas.m3.pb.m3pbcommonstarter.web.bind.OpenApiDataBinder.applyPropertyValues(OpenApiDataBinder.java:47)

Comment From: snicoll

@thomajic thanks for following up, but that's not a sample we can run ourselves. You haven't mentioned in which version this used to work. If you want support, please take the time to prepare a sample we can run ourselves. You can attach a zip to this issue or push the code to a GitHub repository.

Comment From: thomajic

May be you can use the attached for the interval data member which i have created when parsing its still string and its not using the WebMvcConfigurer binding for it it is initialised but not used:

demo.zip

Comment From: snicoll

@thomajic thanks for the sample but this is the third time I am asking. In which Spring Boot version the sample above worked? Also you're mapping a custom Interval object of yours with several fields and I have no idea how you sent that in the request. Where is the converter for it?

Please share also a sample request using curl or HTTPie that we can use to reproduce the problem.

Comment From: rstoyanchev

The attached demo works just fine. I used:

curl -v "http://localhost:8040/test?date.from=2007-12-03T10:15:30.00Z&date.to=2007-12-03T10:15:30.00Z"

On the server side, MyModel is initialized as expected without BindingResult errors.

I gather the issue has something to do with the registration of converters, but you need to provide something that fails. As it is there is no failure, and the registration of the Instant converter makes no difference, because this is already supported. I can remove WebDataBinderConfig completely and it works just the same.

Please, provide a sample that demonstrates the failure.

Comment From: youssef3wi

I think there is an issue in the applyPropertyValues method of your com.adidas.m3.pb.m3pbcommonstarter.web.bind.OpenApiDataBinder.applyPropertyValues(OpenApiDataBinder.java:47).

Comment From: thomajic

Hello everyone i think i got the issue where it fails. Thank you.