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

Getting a list of compact links for an association throws an exception [DATAREST-404]

Open
#781 2 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

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

Description

Dave LeBlanc opened DATAREST-404 and commented

On an object that has a one-to-many association (eg: a set of things) if we get the set without a custom content type, it returns the expected results.

If however we request it in the compact type (application/x-spring-data-compact+json) - which I assume should just return a list of links, the call will throw an exception: "Map has no value for 'repository'". It's trying to build a URL with parameters: /{repository}/{id}/{property}, but all it gives for parameters is "property" -> "items" (looks like it's missing the repo and id properties).

To recreate, use this URL with the restbucks example: http://localhost:8080/orders/1/items

The stack trace is:

2014-11-07 18:14:46,185 ERROR o.s.d.rest.webmvc.AbstractRepositoryRestController: 179 - Map has no value for 'repository'
java.lang.IllegalArgumentException: Map has no value for 'repository'
at org.springframework.web.util.UriComponents$MapTemplateVariables.getValue(UriComponents.java:277) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.UriComponents.expandUriComponent(UriComponents.java:221) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents$FullPathComponent.expand(HierarchicalUriComponents.java:642) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:311) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.HierarchicalUriComponents.expandInternal(HierarchicalUriComponents.java:46) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.UriComponents.expand(UriComponents.java:152) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.util.UriComponentsBuilder.buildAndExpand(UriComponentsBuilder.java:288) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:145) ~[spring-hateoas-0.16.0.RELEASE.jar:na]
at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:135) ~[spring-hateoas-0.16.0.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.followPropertyReferenceCompact(RepositoryPropertyReferenceController.java:264) ~[spring-data-rest-webmvc-2.2.0.RC1.jar:na]


Affects: 2.2 GA (Evans)

3 votes, 3 watchers

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.