spring-cloud-openfeign: @PathVariable is not getting interpolated if the variable is null

@RequestMapping(value = "/items/{id}", method = RequestMethod.PUT)
  ItemResponse updateItem(@PathVariable("id") final Integer id, ItemRequest request);

FeignClient is not throwing any Null pointer exception or Errors when id is null while invoking the above feign client method; it simply send a string {id} to the service, instead of trying to interpolate and fail. This is very misleading IMHO.

My server side was a spring boot app and it had the similar configuration for the PUT endpoint and it went to a http500 with the following exception. java.lang.NumberFormatException: For input string: "{id}"

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

This issue is fixed with https://github.com/spring-cloud/spring-cloud-openfeign/commit/15be7111ec545ea5588dea9b82e3ebc423f57231 (2.1.2.RELEASE) with feign upgrade (>=10.2.0)

Now null path variable parameters are replaced with empty string as defined with RFC 6570 More info: https://github.com/OpenFeign/feign/blob/master/README.md#undefined-vs-empty-values

The API in the example will return 400 or 404, which is correct behavior IMO.