-
Notifications
You must be signed in to change notification settings - Fork 472
Path variable resolved as empty string #1728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the issue is because of his line:
3d7458b#diff-09a17eb7868f85c16a8ee6712c5fdbac7c32c58c83226b78cbc0b980bf8d798c It expands the link so if there is path variables, they're replaced by empty strings. |
Hi, We are currently upgrading our spring boot application from spring boot 2.7.10 -> 3.1.5. This pulls in a newer version of spring-hateoas which we'd like to move too as well (1.3.5 -> 2.1.2). However a whole bunch of our unit tests are failing because of this Just want to report that it also happens for At this stage I'd just like to understand if this is an intentional change in behaviour, incorrect usage of spring hateoas by us or simply a regression. CC: @odrotbohm |
Hi @odrotbohm It would be great if you could have a look that the PR I just linked to this issue. I made a small change to the Our basic usage pattern is to have a resource that clients can get a list of results from (PagedModel). And this model has some affordances added to it as normal (e.g. create a new item). Some of them have additional affordances (POST requests) that advertise to the client that there are other operations they can perform on the list. But they need to provide input to the request. What we do and expect exactly is described better in the linked stackoverflow post. At this point we'd just appreciate some feedback on whether what we are doing and/or expecting is not valid in some way or whether this is simply a regression? |
The change you stumble above was introduced to align with the HAL Forms spec. Values for EDIT: That's even obvious from the change you linked to and the in turn linked issue. See also the discussion attached to the commit. I guess HAL FORMS expects all variable aspects of the transition to be in the form itself, and thus a potential template would have to be expanded on rendering the form. This doesn't seem to be too far fetched as HAL FORMS is very much inspired by HTML forms. |
Thanks for the reply @odrotbohm and for pointing out the discussion on that commit that I'd missed. It does feel like failing rendering might be better than silently producing links containing empty strings (e.g. As well as the problem described in my stackoverflow issue (target with query parameter missing the template variable), this change has thrown a spanner in the works in another area. We have resources as follows
For 3. our response looks like this:
You'll see we emit a template in the root of the response to perform some action at the level of the resource. Here we don't know what the specific Any thoughts would be much appreciated. |
For that particular resource, wouldn't the (already fully expanded) self link be the target anyway? In other words, you shouldn't even need to explicitly declare a target. An easy way to do this is: Affordances.of(selfLink)
.afford(…) // build up templates
.toLink(); That'll use the Regarding the optionality, I fear we're stuck with the definitions in the RFC and that defines "undefined" values to be skipped unconditionally. In other words, if we reject the expansion, we'd not comply with the specification anymore. |
Since version 1.4, path variables are resolved as empty strings instead of template variables in
target
field:The link creation:
The SelectColorController
Before 1.4:
Since 1.4:
The text was updated successfully, but these errors were encountered: