zazuko / rdf-validate-shacl

Validate RDF data purely in JavaScript. An implementation of the W3C SHACL specification on top of the RDFJS stack.
MIT License
95 stars 12 forks source link

phantom resullt details #125

Closed giacomociti closed 2 months ago

giacomociti commented 3 months ago

For certain violations, the report includes completely unrelated result details.

repro:

# shapes
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <https://example.org/> .

ex:personShape a sh:NodeShape ;
    sh:targetClass ex:Person ;
    sh:property [
        sh:path ex:address ;
        sh:message "ex:city should be sh:IRI" ;
        sh:node [
            sh:path ex:city ;
                        sh:nodeKind sh:IRI
        ] ;
    ] .

ex:sizeShape 
    sh:targetObjectsOf ex:size ;
    sh:or (
                [ sh:hasValue ex:small ]
        [ sh:hasValue ex:big ]
    ) .
# data
@prefix ex: <https://example.org/> .

ex:person1 a ex:Person ; ex:address ex:address1 .

ex:address1 ex:city "London" .

ex:tv ex:size ex:big .

A phantom violation:

    sh:focusNode <https://example.org/big> ;
    sh:resultMessage "Value must be <https://example.org/small>" ;

appears as a detail of the correct main violation ("ex:city should be sh:IRI" ).

Notice that the phantom result disappears if we swap small and big in the shape. Likely it is a temporary result of the sh:or evaluation, which should be discarded as soon as the second alternative satisfies the constraint.

Also worth noting that the phantom result is not there if we fix the main issue ("ex:city should be sh:IRI" ).

giacomociti commented 3 months ago

maybe this is a better repro https://s.zazuko.com/2t87BAk, the previous one was a shape not conformant to shacl-shacl