Skip to content

Double sh:inversePath not handled properly #306

@gorczyca

Description

@gorczyca

PySHACL fails to handle double sh:inversePath, causing a false sh:minCount violation.

PySHACL Version: 0.30.1

MWE:

Shape

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

:Shape0 a sh:NodeShape ;
  sh:targetNode :a0 ;
  sh:property [
    sh:path [ sh:inversePath [ sh:inversePath :r0 ] ] ;
    sh:minCount 1
  ] .

Data

@prefix : <https://w3id.org/example#> .

:a0 :r0 :a1 .

Output

Skipping DataGraph clone because PySHACL is operating in inplace mode.
Found 1 SHACL Shapes defined with type sh:NodeShape.
Found 0 SHACL Shapes defined with type sh:PropertyShape.
Found 0 property paths to follow.
Found 1 implied SHACL Shapes based on their properties.
Found 1 implied SHACL Shapes used as values in shape-expecting constraints.
Cached 1 unique NodeShapes and 1 unique PropertyShapes.
Validating DataGraph named N38e5536692c64376bd985412eb13bc08
Checking if Shape <NodeShape https://w3id.org/example#Shape0> defines its own targets.
Identifying targets to find focus nodes.
Milliseconds to find focus nodes: 0.027ms
Found 1 Focus Nodes to evaluate.
Running evaluation of Shape <NodeShape https://w3id.org/example#Shape0>
Milliseconds to find value nodes for focus nodes: 0.001ms
Current shape evaluation path: <NodeShape https://w3id.org/example#Shape0>
Checking conformance for constraint: <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>>
Current constraint evaluation path: <NodeShape https://w3id.org/example#Shape0> -> <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>>
Running evaluation of Shape <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>
Shape was passed 1 Focus Node/s to evaluate.
Running evaluation of Shape <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>
Milliseconds to find value nodes for focus nodes: 0.041ms
Current shape evaluation path: <NodeShape https://w3id.org/example#Shape0> -> <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>> -> <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>
Checking conformance for constraint: <MinCountConstraintComponent on <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>>
Current constraint evaluation path: <NodeShape https://w3id.org/example#Shape0> -> <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>> -> <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1> -> <MinCountConstraintComponent on <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>>
Milliseconds to check constraint <MinCountConstraintComponent on <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>>: 0.430ms
Focus nodes do _not_ conform to constraint <MinCountConstraintComponent on <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>>.
Milliseconds to evaluate shape <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1>: 0.614ms
Milliseconds to check constraint <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>>: 0.688ms
Focus nodes do _not_ conform to constraint <PropertyConstraintComponent on <NodeShape https://w3id.org/example#Shape0>>.
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
        Severity: sh:Violation
        Source Shape: [ sh:minCount Literal("1", datatype=xsd:integer) ; sh:path [ sh:inversePath [ sh:inversePath :r0 ] ] ]
        Focus Node: <https://w3id.org/example#a0>
        Result Path: [ sh:inversePath [ sh:inversePath :r0 ] ]
        Message: Less than 1 values on <https://w3id.org/example#a0>->[ sh:inversePath [ sh:inversePath :r0 ] ]

Milliseconds to evaluate shape <NodeShape https://w3id.org/example#Shape0>: 0.818ms
Checking if Shape <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1> defines its own targets.
Identifying targets to find focus nodes.
Milliseconds to find focus nodes: 0.023ms
Found 0 Focus Nodes to evaluate.
Skipping shape <PropertyShape n5c06d5a683ef46d8a07a9f35012e11d7b1> because it found no focus nodes.
Validation Report
Conforms: False
Results (1):
Constraint Violation in MinCountConstraintComponent (http://www.w3.org/ns/shacl#MinCountConstraintComponent):
        Severity: sh:Violation
        Source Shape: [ sh:minCount Literal("1", datatype=xsd:integer) ; sh:path [ sh:inversePath [ sh:inversePath :r0 ] ] ]
        Focus Node: <https://w3id.org/example#a0>
        Result Path: [ sh:inversePath [ sh:inversePath :r0 ] ]
        Message: Less than 1 values on <https://w3id.org/example#a0>->[ sh:inversePath [ sh:inversePath :r0 ] ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions