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

Wrong validation errors with SHACL #1345

Open
egekorkan opened this issue Dec 28, 2021 · 2 comments
Open

Wrong validation errors with SHACL #1345

egekorkan opened this issue Dec 28, 2021 · 2 comments
Assignees
Labels
Defer to TD 2.0 Semantics Semantics-related issues

Comments

@egekorkan
Copy link
Contributor

If one uses the shacl validation file at https://github.com/w3c/wot-thing-description/blob/main/validation/td-validation.ttl with a shacl validator like https://shacl.org/playground/ or https://www.itb.ec.europa.eu/shacl/any/upload , TDs that contain op in forms are not accepted.

With the second tool, these additional errors also show up:

Details

  • Value must be a valid literal of type string
    Location:[Result path] - [https://www.w3.org/2019/wot/td#hasSecurityConfiguration]
    Test:[Value] - [https://json-ld.org/playground/nosec_sc]
  • Property needs to have at least 1 value
    Location:[Result path] - [https://www.w3.org/2019/wot/td#securityDefinitions]

Since some part of the spec is generated from this file, it is probably normative and needs fixes.

Notes:

  • Both validators show different errors and need a Turtle input for the TD instead of a JSON-LD. I am not sure why the error happens but it can be due to JSON-LD 1.1
  • WoTHive (https://github.com/oeg-upm/wot-hive) developed by @AndreaCimminoArriaga uses the almost same shape file and also does not accept op values. I am not sure what the validation library is but I am guessing something from Apache Jena.
@AndreaCimminoArriaga
Copy link

@egekorkan I changed the implementation since the ontology has changed and now the old shacl shapes throw new errors. For instance, before the key "title" was translated into dct:title but now it is translated into td:title. The shapes forced to have at least one dct:title in a valid TD, therefore now all TDs will not be valid since title is td:title.

I think the file at https://github.com/w3c/wot-thing-description/blob/main/validation/td-validation.ttl has been updated to cope with this new terms. However, I tried with https://shacl.org/playground/ specifying the rdf:type Thing (this is important because the shapes are endowed particularly for this type) and I get more errors:

[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:InConstraintComponent ;
	sh:sourceShape _:n1855 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value "MyLampThing" ;
	sh:resultPath td:title ;
	sh:resultMessage "Value is not in Blank node _:n2014" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:NodeConstraintComponent ;
	sh:sourceShape _:n1855 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value "MyLampThing" ;
	sh:resultPath td:title ;
	sh:resultMessage "Value does not have shape <http://www.w3.org/ns/td-validation#DataSchemaShape>" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
	sh:sourceShape _:n1855 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value "MyLampThing" ;
	sh:resultPath td:title ;
	sh:resultMessage "Value does not have datatype xsd:anyURI" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
	sh:sourceShape _:n1855 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:resultPath td:title ;
	sh:resultMessage "Less than 2 values" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:NodeConstraintComponent ;
	sh:sourceShape _:n1863 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value _:n2139 ;
	sh:resultPath _:n1864 ;
	sh:resultMessage "Value does not have shape <http://www.w3.org/ns/td-validation#InteractionAffordanceShape>" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:NodeConstraintComponent ;
	sh:sourceShape _:n1868 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value _:n2138 ;
	sh:resultPath td:hasEventAffordance ;
	sh:resultMessage "Value does not have shape <http://www.w3.org/ns/td-validation#EventAffordanceShape>" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:DatatypeConstraintComponent ;
	sh:sourceShape _:n1871 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value <https://json-ld.org/playground/basic_sc> ;
	sh:resultPath td:hasSecurityConfiguration ;
	sh:resultMessage "Value does not have datatype xsd:string" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:NodeConstraintComponent ;
	sh:sourceShape _:n1872 ;
	sh:focusNode <urn:dev:ops:32473-WoTLamp-1234> ;
	sh:value _:n2136 ;
	sh:resultPath td:definesSecurityScheme ;
	sh:resultMessage "Value does not have shape <http://www.w3.org/ns/td-validation#SecuritySchemeShape>" ;
] .
[
	a sh:ValidationResult ;
	sh:resultSeverity sh:Violation ;
	sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
	sh:sourceShape _:n1855 ;
	sh:focusNode _:n2136 ;
	sh:resultPath td:title ;
	sh:resultMessage "Less than 2 values" ;
] .

The RDF document was:

<urn:dev:ops:32473-WoTLamp-1234> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#LightSwitch> .
<urn:dev:ops:32473-WoTLamp-1234> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/td#Thing> .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#definesSecurityScheme> _:b0 .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#hasActionAffordance> _:b1 .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#hasEventAffordance> _:b3 .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#hasPropertyAffordance> _:b6 .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#hasSecurityConfiguration> <https://json-ld.org/playground/basic_sc> .
<urn:dev:ops:32473-WoTLamp-1234> <https://www.w3.org/2019/wot/td#title> "MyLampThing" .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/security#BasicSecurityScheme> .
_:b0 <https://www.w3.org/2019/wot/security#in> "header" .
_:b0 <https://www.w3.org/2019/wot/td#hasInstanceConfiguration> <https://json-ld.org/playground/basic_sc> .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#ToggleCommand> .
_:b1 <https://www.w3.org/2019/wot/td#hasForm> _:b2 .
_:b1 <https://www.w3.org/2019/wot/td#name> "toggle" .
_:b2 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <https://mylamp.example.com/toggle> .
_:b3 <https://www.w3.org/2019/wot/td#hasForm> _:b4 .
_:b3 <https://www.w3.org/2019/wot/td#hasNotificationSchema> _:b5 .
_:b3 <https://www.w3.org/2019/wot/td#name> "overheating" .
_:b4 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <https://mylamp.example.com/oh> .
_:b5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#StringSchema> .
_:b6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/saref#OnOffState> .
_:b6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2019/wot/json-schema#StringSchema> .
_:b6 <https://www.w3.org/2019/wot/td#hasForm> _:b7 .
_:b6 <https://www.w3.org/2019/wot/td#name> "status" .
_:b7 <https://www.w3.org/2019/wot/hypermedia#hasTarget> <https://mylamp.example.com/status> .

@egekorkan egekorkan added the V1.1 should be resolved in v1.1 label Apr 20, 2022
@egekorkan egekorkan added Semantics Semantics-related issues Defer to TD 2.0 and removed V1.1 should be resolved in v1.1 labels Nov 23, 2023
@egekorkan egekorkan assigned mahdanoura and unassigned vcharpenay Nov 23, 2023
@mahdanoura
Copy link
Contributor

mahdanoura commented Feb 1, 2024

@AndreaCimminoArriaga I checked this issue. I understand the problem with rdf:type td:Thing, but I am not sure how to resolve this. We cannot enforce this with the json-ld context file, as the @context file does not add an rdf:type relationship when the term is not existent in the json-ld instance.

Also, the SHACL validators seem to behave differently. The shacl playground has a strange behaviour with regards to the xsd:string and rdf:langString. Once the type is string it complains that it should be a langString, and the other way round.

I checked with python pyshacl library there is no validation errors regarding the title.

@egekorkan This is also the case with operations in Forms, this works. There was one issue I found in our SHACL shape graph, where I will do a PR that will fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defer to TD 2.0 Semantics Semantics-related issues
Projects
None yet
Development

No branches or pull requests

4 participants