Problem Creating a Container

32 views
Skip to first unread message

Tim McIver

unread,
Dec 8, 2019, 9:12:17 PM12/8/19
to Trellis LDP
Hi All.  This is my first post here and I want to say thanks to everyone involved in creating/maintaining this project.

I'm also pretty new to all things linked data so my question is likely due to operator error but I can't find a solution so I'm posting here.

I'm following along the LDP Primer and using Trellis as the LDP server.  I'm trying to create a container and to do so I'm using the following turtle:

@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
 
<http://localhost/quotes> a ldp:Container, ldp:BasicContainer ;
    dcterms
:title "A bunch of quotes." ;
    dcterms
:description "Just a bunch of quotes." .

To create the container, I use the following script:

curl -X POST \
     
-H "Link: <http://www.w3.org/ns/ldp/BasicContainer>; rel=\"type\"" \
     
-H "Content-Type: text/turtle" \
     
-H "Slug: quotes" \
     
-d "@quotes-container.ttl" \
     http
://localhost

I don't get an error when running the script.  When I query the root of the server, I see

@prefix schema:  <http://schema.org/> .
@prefix owl:  <http://www.w3.org/2002/07/owl#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix memento:  <http://mementoweb.org/ns#> .
@prefix skos:  <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix acl:  <http://www.w3.org/ns/auth/acl#> .
@prefix geo:  <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix dc11:  <http://purl.org/dc/elements/1.1/> .
@prefix as:  <https://www.w3.org/ns/activitystreams#> .
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ldp:  <http://www.w3.org/ns/ldp#> .
@prefix time:  <http://www.w3.org/2006/time#> .
@prefix prov:  <http://www.w3.org/ns/prov#> .
@prefix dc:  <http://purl.org/dc/terms/> .

<http://localhost/>  ldp:contains  <http://localhost/afdcbac7-cdee-4baf-a01d-e229c21ad7c2> ;
        ldp
:contains  <http://localhost/quotes> .

And when I query the quotes container, I get

# eliding all the @prefix's

<http://localhost/quotes/>
        dc
:title        "A bunch of quotes." ;
        dc
:description  "Just a bunch of quotes." .

This was the first surprise.  I expected to see triples showing that it was a Container but it does not.  And when I attempt to create a resource under localhost/quotes, I get the error

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 Internal Server Error</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /quotes. Reason:
<pre>    Internal Server Error</pre></p>
</body>
</html>

I assume that the error is because localhost/quotes is not actually a Container, but I may be wrong.  I also wouldn't expect Trellis to have an internal server error over this . . .

Can anyone shed any light on this issue for me?  It would be greatly appreciated!

Tim

Aaron Coburn

unread,
Dec 8, 2019, 9:39:15 PM12/8/19
to trell...@googlegroups.com
Hi,Tim,
That's a really sneaky problem, because it's due to a typo in the LDP primer.

The issue is that the LDP IRI in the Link header is incorrect. It should be: http://www.w3.org/ns/ldp#BasicContainer

You may notice that the IRI above has a hash (#) and the (incorrect) one from the LDP primer has a slash before BasicContainer

One small recommendation though: if you plan to POST Turtle with a Slug header, it is better to use a relative IRI such as <> rather than using one with <http://localhost/quotes>. That way, if the server ends up using a value that's different than the Slug value (Slug values are just hints), then your RDF will be what you expect.

I hope that helps.
Cheers,
Aaron

--
You received this message because you are subscribed to the Google Groups "Trellis LDP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trellis-ldp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trellis-ldp/ee541d2c-db8b-4b0e-a456-542631f39ecc%40googlegroups.com.

Tim McIver

unread,
Dec 8, 2019, 11:36:49 PM12/8/19
to Trellis LDP
Aaron,

Thanks for the quick reply.  You know, I thought that too and even tried changing the IRI as you say, but it does not make a difference; I get the same result.  I just tried it again to be sure.  Can you see any other mistakes I'm making?  BTW, I'm deleting the "quotes" resource with "curl -X DELETE localhost/quotes" between each attempt.  Is it possible that Trellis has a relic of that resource that sticks around and fouls up all future attempts to create that resource?

Also, do you happen to know if it's possible to fix that type in the Primer?  It looks like it's been there since at least 2014.

Tim
To unsubscribe from this group and stop receiving emails from it, send an email to trell...@googlegroups.com.

Aaron Coburn

unread,
Dec 9, 2019, 8:52:05 AM12/9/19
to trell...@googlegroups.com
Hi Tim,
Can you tell me which version of Trellis you are using? Are you using the latest release (0.8.3) or are you pulling from the tip of development? Are you building and running the software manually or are you using a docker container from docker hub (if so, which one)? And what backend persistence layer are you using (triplestore or relational database)? 

There are a few issues you mentioned in your initial email. I tried replicated the steps outlined, using the current master branch (with a triplestore backend) and I saw different behavior, though some of this might be due to some commits that were merged just last week.

First of all, you *should* see the `<> a ldp:BasicContainer` triple in a resource. This triple is managed by the server and there is a configuration property to turn that on or off; previously, the default was off but it is now turned on, which will be new behavior for the upcoming 0.9 release.

Secondly, when you create a resource with cURL, I would recommend using the `-i` flag so that you can inspect the response headers. In LDP, there is a lot of information in response headers, especially the Link headers. Those Link headers will always be the canonical source of information about a resource's LDP type (e.g RDFSource or BasicContainer).

And finally, should you first create an RDFSource (not a container) and then try to POST a new resource (as if it were a container), you *should* be getting a `405 Method Not Allowed` error rather than a 500 error. In my tests just now, I receive a 405 error when trying to POST to an ldp:RDFSource (which is an expected response). A POST to a BasicContainer succeeds as expected.

Cheers,
Aaron


To unsubscribe from this group and stop receiving emails from it, send an email to trellis-ldp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trellis-ldp/59e0b3d0-52d7-425f-8116-8166cec6e900%40googlegroups.com.

Tim McIver

unread,
Dec 9, 2019, 8:57:50 AM12/9/19
to Trellis LDP
Aaron,

I'm using version 0.8.3 and I'm running it in a docker container whose image came from docker hub, I believe (I don't recall building it locally).  So perhaps I should build from master . . . The backend persistence store is relational DB (Postgres).

Tim McIver

unread,
Dec 9, 2019, 9:08:37 AM12/9/19
to Trellis LDP
It's fixed!  I just tried the "develop" tag of the "trellisldp/trellis-ext-db" docker image and now it seems to work.  Thanks for the help with this Aaron!

Tim

Aaron Coburn

unread,
Dec 9, 2019, 9:44:17 AM12/9/19
to trell...@googlegroups.com
Tim,
That's good to hear. Using the "develop"-tagged docker images is exactly what I would recommend.
Watch this space for an announcement for the next (0.9) release, which is pretty imminent: this week or next.

Cheers,
Aaron

To unsubscribe from this group and stop receiving emails from it, send an email to trellis-ldp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trellis-ldp/799fe6df-5374-48f4-a38f-880125db5b5d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages