rdf-validate-shacl
rdf-validate-shacl copied to clipboard
JS iterable error when using SHACL model
Depending on the structure of your SHACL shape and its list definitions, you may get obscure errors such as this:
Message:
listNode.list is not a function or its return value is not iterable
Stacktrace:
at rdfListToArray rdf-validate-shacl/src/dataset-utils.js:91 return [...listNode.list()].map(({ term }) => term)
at validateClosed rdf-validate-shacl/src/validators.js:43 allowed.addAll(rdfListToArray(context.$shapes.node(ignoredPropertiesNode)))
at execute rdf-validate-shacl/src/validation-function.js:11 return this.func.apply(globalObject, [this.context, focusNode, valueNode, const…
at validateNodeAgainstConstraint rdf-validate-shacl/src/validation-engine.js:217 const obj = validationFunction.execute(focusNode, valueNode, constraint)
at validateNodeAgainstShape rdf-validate-shacl/src/validation-engine.js:177 if (this.validateNodeAgainstConstraint(focusNode, valueNodes, constraint, dataG…
at validateAll rdf-validate-shacl/src/validation-engine.js:154 if (this.validateNodeAgainstShape(focusNode, shape, dataGraph)) {
at validate rdf-validate-shacl/index.js:36 this.validationEngine.validateAll(this.$data)
This seems to be caused by the clownface list() implementation returning null instead of an iterable (see here
I would have expected no error, or a more informative error instead.
Let me know if you need an MWE, and I'll see whether I can add the M to my WE
It would be valuable to see an example.
tl;dr; the spec requires values of certain properties to be lists. If it's any of those cases, we'd likely. just trade the error message for something more informative
I was able to reproduce this with the following MWE:
prefix : <https://triply.cc/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sh: <http://www.w3.org/ns/shacl#>
:x a :X.
:lst
rdf:first rdf:type;
rdf:rest rdf:nil.
:model {
:lst
rdf:first rdf:type;
rdf:rest rdf:nil.
:X
sh:closed true;
sh:ignoredProperties :lst;
sh:targetNode :x.
}