You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sending a application/sparql-update patch to a container on a SPARQL backend fails with
BadRequestHttpError: Can only create containers with RDF data. The "chunk" argument must be one of type string or Buffer. Received type object
at DataAccessorBasedStore.handleContainerData (/var/www/css.verborgh.org/src/storage/DataAccessorBasedStore.js:205:23)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async DataAccessorBasedStore.writeData (/var/www/css.verborgh.org/src/storage/DataAccessorBasedStore.js:179:13)
at async DataAccessorBasedStore.setRepresentation (/var/www/css.verborgh.org/src/storage/DataAccessorBasedStore.js:110:9)
at async SparqlUpdatePatchHandler.applyPatch (/var/www/css.verborgh.org/src/storage/patch/SparqlUpdatePatchHandler.js:91:9)
at async SparqlUpdatePatchHandler.handle (/var/www/css.verborgh.org/src/storage/patch/SparqlUpdatePatchHandler.js:57:13)
at async MonitoringStore.modifyResource (/var/www/css.verborgh.org/src/storage/MonitoringStore.js:38:9)
at async PatchOperationHandler.handle (/var/www/css.verborgh.org/src/ldp/operations/PatchOperationHandler.js:18:9)
at async AuthenticatedLdpHandler.handle (/var/www/css.verborgh.org/src/ldp/AuthenticatedLdpHandler.js:45:61)
at async AllVoidCompositeHandler.handle (/var/www/css.verborgh.org/src/util/AllVoidCompositeHandler.js:17:17)
In the case of SPARQL this is going to fail because the data has already been parsed so there should be a check for this.
Related to that: using the parseQuads function as it currently is written is also not ideal since that function assumes text/turtle, but this is related to #341 .
It's actually going to be a bit more difficult than this. Making sure containers can also accept quads as body is easy. The problem is when doing a patch.
To do a patch we request all triples, do the change, and send them back. In the case of containers this means this set of triples is going to have containment triples, since we present the metadata of a container as data as well. This means that the representation that the patch requests sends back will have those triples. But it is forbidden to write containment triples to a container! (If we do a change here to fix this we will also have to make sure the patch can't edit those triples).
Besides that a lot of metadata for containers is generated on the fly (such as all the extra metadata about the resources in the container) which we actually don't want to write back.
Random idea since this we just had another issue related to data/metadata being (almost) the same for containers (the other one being the one with the content-type): perhaps we want only store the metadata that was added by the agent in the data object of the container and all the rest (so everything that we generate such as containment triples) in the metadata. Then we could have a separate responsewriter for containers that merges the two into a single data stream. Or perhaps a specific resourcestore makes more sense. This way we only do the merge at the end of the pipeline instead of the beginning as we do now so we can easily still edit it (such as patching).
I've been thinking a bit more on this since I feel this touches on some of the core assumptions currently made in the server.
First of all, the suggestion above would be helpful in some cases (such as filtering out certain containment triples), but it would be hard to consistently say what belongs in the metadata and what in the data which would make certain other cases more complicated (such as patching). It might make sense to have representations with metadata but without data specifically for containers.
The issue here is related to how we treat metadata in general. Currently it is impossible to directly access the metadata of a document directly: we expose (some of) it through the response headers on a GET/HEAD request. The only way to change the metadata is to do a PUT request with new headers to overwrite the stored metadata. This also means it is impossible to change the metadata without changing the data itself. Perhaps we do want to do this (since this is also what NSS did)? This would require pulling some parts of the metadata logic to a higher and more general level and perhaps would require some interface changes (not sure about this yet).
The reason I mention the metadata above is because that's what a patch of a container is: editing the metadata. Containers have no actual data, this is just obfuscated by presenting the metadata as also being the data. This means that a patch on a container would imply editing the metadata which as mentioned above is not possible for documents.
If we do change it up so that metadata can be edited independently there are some things that would have to be taken into account there. For example, there would defintely need to be checks to make sure certain metadata is not changed (containment triples, if the resource is a container or not, etc.).
None of this solves the problem of how to patch the container metadata that contains generated metadata though. One problem is the containment triples. Perhaps that could be solved by having a SparqlPatchHandler that wraps around another PatchHandler but first removes all containment triples from the metadata. Then we still have the non-containment generated metadata. The worst offender for this is the file data accessor since that one also adds metadata about all the resources in a container. What I'm thinking of there is either making sure a data accessor recognizes the metadata as something it would generate itself and remove it before storing the rest, or extending the wrapping PatchHandler mentioned above to remove it there.
I understand the language that's being used here / in this issue may be closer to implementation's classification of things, but I'm curious.. if a client wants to give the container a human-readable label, is that "data" or "metadata" for CSS? Which resource URL (container or auxiliary) would include the triple with the label?
I'm bringing this up if by chance there is any oversight: as far as the Solid specification is concerned, the resource [in this case the container] is self-descriptive, so the label would appear in the description of the resource as "data", as opposed to the auxiliary resource as "metadata". For non RDF resources, label could be anywhere eg. a resource with an RDF representation referring to the image may include the triple, or possibly even image's auxiliary resource (via describedby) may include the label triple - in this case, it would be more like a "metadata".
Activity
jvherweg commentedon Dec 4, 2020
This is because the
DataAccessorBasedStoretries to parse the input to see if it is RDFhttps://github.com/solid/community-server/blob/35aec9cce7d1bf5fc81308f5a89b545ff342f346/src/storage/DataAccessorBasedStore.ts#L243
In the case of SPARQL this is going to fail because the data has already been parsed so there should be a check for this.
Related to that: using the
parseQuadsfunction as it currently is written is also not ideal since that function assumestext/turtle, but this is related to #341 .jvherweg commentedon Dec 4, 2020
It's actually going to be a bit more difficult than this. Making sure containers can also accept quads as body is easy. The problem is when doing a patch.
To do a patch we request all triples, do the change, and send them back. In the case of containers this means this set of triples is going to have containment triples, since we present the metadata of a container as data as well. This means that the representation that the patch requests sends back will have those triples. But it is forbidden to write containment triples to a container! (If we do a change here to fix this we will also have to make sure the patch can't edit those triples).
Besides that a lot of metadata for containers is generated on the fly (such as all the extra metadata about the resources in the container) which we actually don't want to write back.
jvherweg commentedon Dec 4, 2020
Random idea since this we just had another issue related to data/metadata being (almost) the same for containers (the other one being the one with the content-type): perhaps we want only store the metadata that was added by the agent in the
dataobject of the container and all the rest (so everything that we generate such as containment triples) in the metadata. Then we could have a separate responsewriter for containers that merges the two into a single data stream. Or perhaps a specific resourcestore makes more sense. This way we only do the merge at the end of the pipeline instead of the beginning as we do now so we can easily still edit it (such as patching).jvherweg commentedon Dec 8, 2020
I've been thinking a bit more on this since I feel this touches on some of the core assumptions currently made in the server.
First of all, the suggestion above would be helpful in some cases (such as filtering out certain containment triples), but it would be hard to consistently say what belongs in the metadata and what in the data which would make certain other cases more complicated (such as patching). It might make sense to have representations with metadata but without data specifically for containers.
The issue here is related to how we treat metadata in general. Currently it is impossible to directly access the metadata of a document directly: we expose (some of) it through the response headers on a GET/HEAD request. The only way to change the metadata is to do a PUT request with new headers to overwrite the stored metadata. This also means it is impossible to change the metadata without changing the data itself. Perhaps we do want to do this (since this is also what NSS did)? This would require pulling some parts of the metadata logic to a higher and more general level and perhaps would require some interface changes (not sure about this yet).
The reason I mention the metadata above is because that's what a patch of a container is: editing the metadata. Containers have no actual data, this is just obfuscated by presenting the metadata as also being the data. This means that a patch on a container would imply editing the metadata which as mentioned above is not possible for documents.
If we do change it up so that metadata can be edited independently there are some things that would have to be taken into account there. For example, there would defintely need to be checks to make sure certain metadata is not changed (containment triples, if the resource is a container or not, etc.).
None of this solves the problem of how to patch the container metadata that contains generated metadata though. One problem is the containment triples. Perhaps that could be solved by having a SparqlPatchHandler that wraps around another PatchHandler but first removes all containment triples from the metadata. Then we still have the non-containment generated metadata. The worst offender for this is the file data accessor since that one also adds metadata about all the resources in a container. What I'm thinking of there is either making sure a data accessor recognizes the metadata as something it would generate itself and remove it before storing the rest, or extending the wrapping PatchHandler mentioned above to remove it there.
csarven commentedon Dec 8, 2020
I understand the language that's being used here / in this issue may be closer to implementation's classification of things, but I'm curious.. if a client wants to give the container a human-readable label, is that "data" or "metadata" for CSS? Which resource URL (container or auxiliary) would include the triple with the label?
I'm bringing this up if by chance there is any oversight: as far as the Solid specification is concerned, the resource [in this case the container] is self-descriptive, so the label would appear in the description of the resource as "data", as opposed to the auxiliary resource as "metadata". For non RDF resources, label could be anywhere eg. a resource with an RDF representation referring to the image may include the triple, or possibly even image's auxiliary resource (via describedby) may include the label triple - in this case, it would be more like a "metadata".
[-]Sending SPARQL PATCH to container fails[/-][+]Sending PATCH to container fails[/+]RubenVerborgh commentedon Jan 29, 2021
Let's pause this until solid/specification#198 has been fully done.
jvherweg commentedon Sep 23, 2021
Added in #955