Skip to content
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

embeddeds without self-link shouldn't be dropped #487

Closed
beuss opened this issue Nov 27, 2023 · 1 comment
Closed

embeddeds without self-link shouldn't be dropped #487

beuss opened this issue Nov 27, 2023 · 1 comment

Comments

@beuss
Copy link

beuss commented Nov 27, 2023

When an embedded does not contain a self-link, a warning is printed and the item is ignored. While the spec looks contradictory, the embedded should not be ignored
The HAL spec is clear on this point:

The reserved "_links" property is OPTIONAL.

The HAL-FORMS spec looks contradictory since it states:

[the link element] is a RECOMMENDED element

and then (while this looks to break HAL backward compatibility)

Every HAL-FORMS document SHOULD have at least one link element in the collection with a key value set to self
[…]
Clients MAY reject a HAL-FORMS document that does not contain a link element with the key value set to self.

It recommends to defaults self-link to the URI used for the request but this looks incompatible with current cache handling in ketting since URI is used as a cache key

Is there any hope to have this behavior fixed?

@evert
Copy link
Collaborator

evert commented Sep 22, 2024

Ketting right now does not not aim to be a perfect client for every use-cases of HAL. Ketting is opinionated and needs certain things to be true to fit its architecture. We also need to support a number of different formats, and find a lowest common denominator.

This sometimes means trade-offs, and one of those trade-offs is is that if a hypermedia API (regardless of format) uses a concept of embedded/transcluded resources then it needs those resources to be globally identifiable through a URI.

If you have control over the server, I would suggest simply adding a self link pointing to something unresolvable like a urn: URI. Frankly I find the idea of using a subresource/embedded resource without a URI really strange, and wonder if this should not have been a regular property on your resource.

The only workaround I can see adding in Ketting in the future is to give users some way to get access to the raw underlying HAL response, but I have no immediate plans to do this.

For now I think it's best to close this, because I can't honestly say at the moment if this will ever become a priority, I'm sorry! The ugly thing you can do right now is call .fetch() directly on a resource but I totally understand this is annoying as you opt-out of all the other features.

@evert evert closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants