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

Resource creation behaviour when using the Slug header #96

Open
NSeydoux opened this issue Oct 18, 2019 · 13 comments
Open

Resource creation behaviour when using the Slug header #96

NSeydoux opened this issue Oct 18, 2019 · 13 comments

Comments

@NSeydoux
Copy link

In the current LDP specification, a client is allowed to hint for a resource name at creation time by setting the Slug header in the POST request (see section 5.2.3.10). However, since the usage of the Slug header is quite flexible, the LDP spec does not specify the expected behaviour when requesting for the creation of a resource with a slug that's already present in the parent's containments.

Depending on the implementation, different behaviours may therefore be expected:

  • Preventing the creation of a new resource with the same slug altogether, and returning a 409 Conflict response to the client, potentially including a Link <iri>; rel="ldp:constrainedBy" header, wit iri pointing to a vocabulary defining a term specifying "The requested IRI already exists"
  • Creating the resource combining the slug to a generated ID, and returning the resource IRI to the client in the response's Location header

Since these two behaviours are compliant by the LDP spec, I don't know if imposing one over the other is desirable in the Solid spec, but it may be worth mentioning that these outcomes are possible in the LDP section of the Solid spec, as a non-normative remark.

Do you think this needs to be addressed, and if so as a normative or a non-normative bit ?

@csarven
Copy link
Member

csarven commented Oct 18, 2019

That sounds like useful non-normative material. Irrespective of Slug, one way to frame the core case could be based on this given:

LDP servers that allow member creation via POST SHOULD NOT re-use URIs.

Servers can implement that recommendation by prohibiting any attempts to update existing resources - 409. A more accurate and complex implementation may examine the representation and determine whether it is within acceptable reuse.

The exact application of Slug to determine the final resource URI is an implementation detail. I don't think that needs to be emphasised.

@kjetilk
Copy link
Member

kjetilk commented Oct 18, 2019

That sounds like useful non-normative material.

Yup, definitly. Should we put it on the June milestone?

@csarven csarven added this to the June 19th milestone Oct 18, 2019
@csarven
Copy link
Member

csarven commented Oct 19, 2019

Thinking further..

While servers can choose to handle Slug as they please, it may be preferable for clients that are making the effort in suggesting a URI to be least surprised.

If servers runs into the URI reuse case, it should reject the request instead of creating a resource with a different name. It gives clients the opportunity to be aware of an existing resource with the same name, and resolve the conflict eg. try a different Slug value.

FWIW:

mkdir /tmp
mkdir: cannot create directory ‘/tmp’: File exists

as opposed to creating for example /tmp-foo/.

Moreover, it is worthwhile to note server's environment for security and privacy purposes. That is, if the server returns a 409 and indicates that a resource with the same name exists, it may be exposing information it doesn't necessarily want to. On the other hand, if a resource is generated with a different name than what's suggested in the Slug, it may or may not mean that the desired name necessarily exists. While the client can always try GET, HEAD, OPTIONS to see the existence of a URI, authn/z applies in any case. (See also: #14 )

@csarven
Copy link
Member

csarven commented Dec 18, 2019

#107 should be resolved before resolving this issue. Will probably reuse heuristics.

@kjetilk
Copy link
Member

kjetilk commented Dec 18, 2019

When rereading this issue, I found that there two separate issues that fit pretty well with the headline, but not with the description of @NSeydoux . :-) One is what should be done when there is an existing resource with the same identifier. The other is how the Slug behaves with relation to containers and stuff. The latter, I believe, needs to be normative material. The former, I still think of as a best practice thing.

@csarven
Copy link
Member

csarven commented Jan 1, 2020

Servers using the Slug value in the algorithm to generate the new URI SHOULD apply the slash semantics.

@RubenVerborgh
Copy link
Contributor

new URI SHOULD apply the slash semantics

Given #128 (comment), we might want that to be a MUST.

@elf-pavlik
Copy link
Member

I think Best Practices note could include guidance on using Slug header. Since client can't rely on server honoring it, probably creating new resource with PUT provides way for client to ensure creation at specific IRI. I think someone developing client may prefer to use reliable PUT than handle case where client hints certain slug but server ignores it.

@RubenVerborgh

This comment has been minimized.

@elf-pavlik
Copy link
Member

elf-pavlik commented Feb 18, 2020

Client always need to be prepared for servers ignoring a slug; slugs are only a suggestion.

I tried suggesting use of PUT as best practice to create new resource at specific IRI, instead of POST + Slug. This way client will simply not need to deal with server ignoring the Slug.
Instead of trying to accomplish goal using an unreliable approach, client can simply accomplish same goal using a reliable approach.

@RubenVerborgh

This comment has been minimized.

@kjetilk
Copy link
Member

kjetilk commented Feb 18, 2020

Yes, I think we agree on that, but note that the original issue text is about what to do when there are existing resources.

Perhaps a change of title would clarify?

How about "Behaviour of Slug header when it would collide with an existing resource with the same identifier." Or something like that. What do you think, @NSeydoux ?

@csarven
Copy link
Member

csarven commented Feb 18, 2020

The title you're proposing is basically #107 with the use of Slug. The effective request URI will be processed all the same with or without Slug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants