spring-projects / spring-projects/spring-data-rest

PUT does not use the configured conversion service for key conversion [DATAREST-1253]

Open
#1,615 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

status: feedback-provided type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Ryon Day opened DATAREST-1253 and commented

For some reason, the hard-coded DefaultConversionService within PersistentEntityResourceHandlerMethodArgumentResolver is preventing deserializing the id in the URL to the id type. 

The result of this is that PUT operations are made impossible.

The weird thing is that there are several points in the flow where the correct ConversionService is used, and the correct Converter is invoked to convert from String to the ID! 

The exact error is:

Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [com.ryonday.sdrputisbroke.domain.ThingieId]

In the sample project, I've explicitly registered a converter for this id type. It seems very misleading and confusing to hard-code a ConversionService with new, when Spring-Data-REST explicitly allows the end user to configure a ConversionService that ostensibly would be used throughout SDR.

I have created a project on GitHub with tests that illustrates this issue. There appears to be no workaround at this time. 

Note that the version of SDR used with Spring Boot 1.5.x did not manifest this issue (although I noticed there is still a hard-coded Conversion Service in the same spot)


Affects: 3.0.7 (Kay SR7)

Reference URL: https://github.com/ryonday/DATAREST-1253

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.