fix: Add IANA type to child metadata in FileDataAccessor - #1237
Conversation
| this.addPosixMetadata(metadata, childStats); | ||
| // Containers will not have a content-type | ||
| if (childLink.contentType) { | ||
| metadata.add(RDF.terms.type, toNamedTerm(`${IANA.namespace}${childLink.contentType}#Resource`)); |
There was a problem hiding this comment.
We'll need to sanity-check childLink.contentType unfortunately. Unless this is done elsewhere—but still. We don't want to be tricked into writing weird things.
There was a problem hiding this comment.
What exactly is the potential issue that you see here? It will always just be a named node in a triple, so converters should have no issue with it to convert it to valid turtle (or other format).
There was a problem hiding this comment.
childLink.contentType = 'a very weird content type' resulting in an invalid RDF term, hence invalid RDF, hence parser failure.
There was a problem hiding this comment.
If we write invalid RDF I would see that as an issue with our serializer since that is going to convert this NamedNode to turtle and is responsible for generating valid RDF. But I'll just add a parseContentType wrapped by a try/catch here to make sure the request doesn't fail if there is a child with an invalid type.
There was a problem hiding this comment.
Nah, RDF/JS assumes that created named nodes are valid. We could have a sanity check in toNamedTerm, but I think it's better here.
an issue with our serializer
This would mean that the serializer checks every single term; would be a massive slowdown. Rather best to assume that NamedNode behaves correctly.
📁 Related issues
Closes #1207
✍️ Description
No breaking changes so can go directly into main.