spring-projects / spring-projects/spring-hateoas
Cannot convert PathVariable Map<String,String> when building link
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
In building some infrastructure, we want to use a Map for the path variables
public List<Resource> list(@PathVariable Map<String, String> pathVariables) { ... }
However when we want to build a list using a map:
methodOn(TheController.class).list(mapOfPathVariables)
We get:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [@org.springframework.web.bind.annotation.PathVariable java.util.Map<java.lang.String, java.lang.String>] to type [java.lang.String]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:206) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.hateoas.mvc.AnnotatedParametersParameterAccessor$BoundMethodParameter.asString(AnnotatedParametersParameterAccessor.java:192) ~[spring-hateoas-0.23.0.RELEASE.jar:na]
at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:150) ~[spring-hateoas-0.23.0.RELEASE.jar:na]
at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:193) ~[spring-hateoas-0.23.0.RELEASE.jar:na]
Looking at exiting PRs, it seems that a similar issue for property placeholders is in progress on @gregturn's PR #602
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AnnotatedParametersParameterAccessor.BoundMethodParameter.asString and the link-building path through ControllerLinkBuilderFactory.linkTo, using the controller and Map invocation shown in the report. Reproduce the ConverterNotFoundException, then verify that building the link accepts the map path variables without that conversion failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100