Describe the bug A dynamic Feign client generated from Spring MVC annotations is not working correctly with URI request parameters. Providing a null value for an optional URI parameter triggers an exception in RequestTemplateFactoryResolver:

java.lang.IllegalArgumentException: URI parameter 1 was null

    at feign.Util.checkArgument(Util.java:110)
    at feign.RequestTemplateFactoryResolver$BuildTemplateByResolvingArgs.create(RequestTemplateFactoryResolver.java:89)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:65)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:96)

Providing a non-null value leads to a client trying to send request to the specified URI(overriding the url provided in @FeignClient) in addition to sending the value as a parameter.

Sample

This is the request definition used for the client:

  @RequestMapping(method = RequestMethod.POST,
      value = "/server/resources",
      produces = {"application/json"},
      consumes = {"multipart/form-data"})
  ResponseEntity<ApiResponse> createResource(@RequestPart(value = "file") MultipartFile file,
      @RequestParam(value = "callbackUrl", required = false) URI callbackUrl);

Take a look at the sample repository for a reproducible example.

Additional context Initially the issue was specifically with Feign throwing an exception on null value for an optional parameter, but it looks like this is caused by an incorrect assumption that the provided URI value should be used as a dynamic URL.

Such behavior was originally encountered in 3.0.8, but is also present in the latest version. Likely connected to https://github.com/OpenFeign/feign/issues/2039

Comment From: OlgaMaciaszek

Hello @Seregy, it's a feature of the underlying OpenFeign/Feign library that a URI passed as an argument is used specifically to override the configured url (see doc). You might want to create an issue with them to, for example, allow disabling such behaviour with a flag, although I'm not sure they would want to implement it.

Comment From: spring-cloud-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: Seregy

Thank you for the response