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

JS iterable error when using SHACL model #73

Open
LaurensRietveld opened this issue Sep 23, 2021 · 2 comments
Open

JS iterable error when using SHACL model #73

LaurensRietveld opened this issue Sep 23, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@LaurensRietveld
Copy link
Contributor

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

@tpluscode
Copy link
Collaborator

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

@wouterbeek
Copy link

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.
}

@martinmaillard martinmaillard added the enhancement New feature or request label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants