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

SHACL: More descriptive message when a shape is both a sh:NodeShape and a sh:PropertyShape #4289

Open
barthanssens opened this issue Nov 21, 2022 Discussed in #4287 · 5 comments
Assignees
Labels
🐞 bug issue is a bug 📦 SHACL affects the SHACL validator
Milestone

Comments

@barthanssens
Copy link
Contributor

Discussed in #4287

Originally posted by volkerjaenisch November 19, 2022
Dear RDF4J Users!

Currently we am implementing SHACL for an OpenData portal (http://datenadler.de).
We are Python programmers so we planed to go with pySHACL. But our Plan B is RDF4J which we are currently using as our backend.

Testing our Plan B we stumbled over the following exception of RDF4J reading a SHAPE file.

javax.servlet.ServletException: org.eclipse.rdf4j.repository.RepositoryException: Shape with multiple types: <http://www.w3.org/ns/shacl#PropertyShape>, <http://www.w3.org/ns/shacl#NodeShape>
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.handleRequest(WorkbenchServlet.java:160)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.service(WorkbenchServlet.java:112)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchGateway.service(WorkbenchGateway.java:117)
	org.eclipse.rdf4j.workbench.base.AbstractServlet.service(AbstractServlet.java:129)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.eclipse.rdf4j.workbench.proxy.CacheFilter.doFilter(CacheFilter.java:64)
	org.eclipse.rdf4j.workbench.proxy.CookieCacheControlFilter.doFilter(CookieCacheControlFilter.java:56)

Root Cause

org.eclipse.rdf4j.repository.RepositoryException: Shape with multiple types: <http://www.w3.org/ns/shacl#PropertyShape>, <http://www.w3.org/ns/shacl#NodeShape>
	org.eclipse.rdf4j.http.client.SPARQLProtocolSession.execute(SPARQLProtocolSession.java:1095)
	org.eclipse.rdf4j.http.client.SPARQLProtocolSession.executeNoContent(SPARQLProtocolSession.java:1049)
	org.eclipse.rdf4j.http.client.RDF4JProtocolSession.upload(RDF4JProtocolSession.java:1103)
	org.eclipse.rdf4j.http.client.RDF4JProtocolSession.upload(RDF4JProtocolSession.java:928)
	org.eclipse.rdf4j.http.client.RDF4JProtocolSession.upload(RDF4JProtocolSession.java:919)
	org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.add(HTTPRepositoryConnection.java:447)
	org.eclipse.rdf4j.workbench.commands.AddServlet.add(AddServlet.java:94)
	org.eclipse.rdf4j.workbench.commands.AddServlet.doPost(AddServlet.java:53)
	org.eclipse.rdf4j.workbench.base.TransformationServlet.service(TransformationServlet.java:98)
	org.eclipse.rdf4j.workbench.base.AbstractServlet.service(AbstractServlet.java:129)
	org.eclipse.rdf4j.workbench.proxy.ProxyRepositoryServlet.service(ProxyRepositoryServlet.java:100)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.service(WorkbenchServlet.java:215)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.handleRequest(WorkbenchServlet.java:137)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchServlet.service(WorkbenchServlet.java:112)
	org.eclipse.rdf4j.workbench.proxy.WorkbenchGateway.service(WorkbenchGateway.java:117)
	org.eclipse.rdf4j.workbench.base.AbstractServlet.service(AbstractServlet.java:129)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.eclipse.rdf4j.workbench.proxy.CacheFilter.doFilter(CacheFilter.java:64)
	org.eclipse.rdf4j.workbench.proxy.CookieCacheControlFilter.doFilter(CookieCacheControlFilter.java:56)

Can someone please explain what is going wrong.

The shape file comes from the EU
https://github.com/SEMICeu/DCAT-AP/blob/master/releases/2.1.1/dcat-ap_2.1.1_shacl_shapes.ttl

pySHACL reads and uses this file with no complains. I also checked graphDB (to make sure my RDF4J is installed correctly) with the exact same outcome.

Any help appreciated

Cheers,
Volker

@barthanssens barthanssens added the 🐞 bug issue is a bug label Nov 21, 2022
@barthanssens barthanssens added this to the 4.2.2 milestone Nov 21, 2022
@barthanssens
Copy link
Contributor Author

barthanssens commented Nov 21, 2022

Looks like the exception is thrown when a SHACL shape has a sh:name

Eg.

:Agent_Shape
    a sh:NodeShape ;
    sh:name "Agent"@en ;
    sh:property [
        sh:minCount 1 ;
        sh:nodeKind sh:Literal ;
        sh:path foaf:name ;
        sh:severity sh:Violation
    ], [
        sh:maxCount 1 ;
        sh:path dct:type ;
        sh:severity sh:Violation
    ] ;
    sh:targetClass foaf:Agent .

Doesn't work, but simply removing the sh:name "Agent"@en fixes it.

@barthanssens barthanssens added 📦 SHACL affects the SHACL validator 📶 enhancement issue is a new feature or improvement labels Nov 21, 2022
@barthanssens
Copy link
Contributor Author

barthanssens commented Nov 21, 2022

Arguably this is not a bug, since, according to the SHACL ontology (https://github.com/w3c/data-shapes/blob/gh-pages/shacl/shacl.ttl), sh:name is only a property of a sh:PropertyShape

While the DCAT-AP shacl file uses it on sh:NodeShape ...

It would be nice to have a bit more logging on which subject/shape the SHACL sail is failing (in this particular case: all nodeshapes), and/or to simply ignore sh:name and sh:description on NodeShapes

@barthanssens barthanssens removed the 🐞 bug issue is a bug label Nov 21, 2022
@hmottestad hmottestad added the specification issues related to compliance to standards and external specs label Nov 21, 2022
@hmottestad
Copy link
Contributor

Improved logging would be nice.

@hmottestad
Copy link
Contributor

Might also be nice to have a "skip invalid shapes" option.

@hmottestad hmottestad changed the title SHACL: sh:name on shapes throws an exception SHACL: More descriptive message when shapes are both sh:NodeShape and sh:TargetShape Dec 1, 2022
@hmottestad hmottestad added 🐞 bug issue is a bug and removed 📶 enhancement issue is a new feature or improvement specification issues related to compliance to standards and external specs labels Dec 1, 2022
@hmottestad
Copy link
Contributor

I’m going to handle this by improving the error message. If I can I will try to add some kind of backwards tracing to log the reason for a shape being both a node shape and a property shape.

I won’t introduce a way to skip invalid shapes at the moment.

@hmottestad hmottestad self-assigned this Dec 1, 2022
@hmottestad hmottestad changed the title SHACL: More descriptive message when shapes are both sh:NodeShape and sh:TargetShape SHACL: More descriptive message when a shape is both a sh:NodeShape and a sh:TargetShape Dec 1, 2022
@hmottestad hmottestad changed the title SHACL: More descriptive message when a shape is both a sh:NodeShape and a sh:TargetShape SHACL: More descriptive message when a shape is both a sh:NodeShape and a sh:PropertyShape Dec 1, 2022
@hmottestad hmottestad modified the milestones: 4.2.2, 4.2.3 Dec 1, 2022
@github-project-automation github-project-automation bot moved this to 📋 Backlog in RDF4J Planning Jan 3, 2023
@abrokenjester abrokenjester moved this from 📋 Backlog to 🏗 In progress in RDF4J Planning Jan 3, 2023
@hmottestad hmottestad modified the milestones: 4.2.3, 4.2.4 Feb 11, 2023
@abrokenjester abrokenjester modified the milestones: 4.2.4, 4.2.5 Apr 22, 2023
@hmottestad hmottestad removed this from the 4.2.5 milestone Jun 1, 2023
@hmottestad hmottestad added this to the 4.3.5 milestone Jul 22, 2023
@hmottestad hmottestad modified the milestones: 4.3.5, 4.3.6 Aug 6, 2023
@hmottestad hmottestad modified the milestones: 4.3.6, 4.3.7 Aug 27, 2023
@hmottestad hmottestad modified the milestones: 4.3.7, 4.3.8 Oct 6, 2023
@hmottestad hmottestad modified the milestones: 4.3.8, 4.3.9 Nov 7, 2023
@hmottestad hmottestad modified the milestones: 4.3.9, 4.3.10 Jan 21, 2024
@hmottestad hmottestad modified the milestones: 4.3.10, 4.3.11 Mar 6, 2024
@hmottestad hmottestad modified the milestones: 4.3.11, 4.3.12 Apr 1, 2024
@hmottestad hmottestad modified the milestones: 4.3.12, 4.3.13 Jun 4, 2024
@hmottestad hmottestad modified the milestones: 4.3.13, 5.0.2 Jul 24, 2024
@hmottestad hmottestad modified the milestones: 5.0.2, 5.0.3 Aug 2, 2024
@hmottestad hmottestad modified the milestones: 5.0.3, 5.0.4 Nov 10, 2024
@hmottestad hmottestad modified the milestones: 5.0.4, 5.1.1 Nov 21, 2024
@hmottestad hmottestad modified the milestones: 5.1.1, 5.1.2 Jan 28, 2025
@hmottestad hmottestad modified the milestones: 5.1.2, 5.1.3 Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug 📦 SHACL affects the SHACL validator
Projects
None yet
Development

No branches or pull requests

3 participants