Closed Sophietje closed 10 months ago
In GitLab by @han.kruiger.tno.nl on Jul 26, 2022, 08:02
Hi Davide,
Thanks for reaching out!
The reason that the validation is complaining here is because there are bindings in the ANSWER that do not 'fit' on the bindings that were sent in the ASK.
For example, the binding in the ASKing Knowledge Base sets (among other things) the "name"
value to "\"-\"^^<http://www.w3.org/2001/XMLSchema#string>"
. This is like a query that SHOULD result only in an answer where the "name"
values are also set to the same thing.
The error tells you that that specific binding (the 2nd one in the ANSWER, with "name"
= "\"Lavatrice\"^^\u003chttp://www.w3.org/2001/XMLSchema#string\u003e"
) has no corresponding binding in the ASK bindings, as it conflicts with the singular binding that is in there (the one where "name"
is set to "\"-\"^^<http://www.w3.org/2001/XMLSchema#string>"
).
There is also an example of how this validation works in this issue.
PS (but this is a separate issue, I think): It appears that sometimes, there is a formatting issue for the <
and >
in the JSON. I see that it's in there as \u003c
and \u003e
, which are their unicode codes.
I hope this helps. Let me know if it is still unclear.
Best, Han
In GitLab by @facoelho on Jul 26, 2022, 09:03
Dear @han.kruiger.tno.nl. I am collecting some other questions from partners that are falling into the same error.
So if I understood correctly, the problem in the case fo Davide is because 'name' in the ANSWER and 'name' in the ASK are not equal?
Can you provide an example, please?
In GitLab by @davide_micheletto_reply.whirlpool.com on Jul 26, 2022, 09:24
Yes, thank you, an example would be appreciated.
In our example, starting from two data (token and playerId) the other fields must be received in response. What would be a correct interaction?
In GitLab by @han.kruiger.tno.nl on Jul 26, 2022, 09:27
So if I understood correctly, the problem in the case fo Davide is because 'name' in the ANSWER and 'name' in the ASK are not equal?
@facoelho Correct, this is the reason. Or rather one of the reasons. The same holds for some of the other variables.
Can you provide an example, please?
Does the following example suffice?
Consider two KBs, KB1 and KB2.
KB1 has the following ASK
KI:
?city :isCapitalOf ?country .
KB2 has the ANSWER
KI with the same graph pattern.
Now, when KB1
triggers its ASK
KI with the following binding set:
[{
"country": "<https://example.org/Germany>"
}]
(effectively asking "What is the capital of Germany?")
and if KB1 then responds with this:
[{
"city": "<https://example.org/Stockholm>",
"country": "<https://example.org/Sweden>",
}]
(effectively answering with "The capital of Sweden is Stockholm!")
This new validation will not allow that anymore.
The answering KB MUST have country
set to <https://example.org/Germany>
in each of its bindings. (So, returning an empty binding set is still allowed!)
Similarly, if KB1 triggered its ASK
with the following binding set:
[
{ "country": "<https://example.org/Germany>" },
{ "country": "<https://example.org/France>" }
]
(effectively asking for the capitals of Germany and France)
then the answering KB1 must have either Germany or France filled into the country
variable in each of its bindings.
In GitLab by @han.kruiger.tno.nl on Jul 26, 2022, 09:33
In your scenario, an example of a valid interaction would be the following:
ASK sends:
[
{
"playerid": "\"xyz\"^^<http://www.w3.org/2001/XMLSchema#string>",
"token": "\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjIzMTMxLCJSb2xlTmFtZSI6IlNUQU5EQVJEX1VTRVIiLCJjb21wYW55SWQiOjAsIlVzZXJOYW1lIjoiRmVkZXJpY2FJbmRlcnN0IiwidXNlcl9uYW1lIjoiRkVERVJJQ0EuSU5ERVJTVEBHTUFJTC5DT00iLCJzY29wZSI6WyJ0cnVzdCIsInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE2NTcyMDQ2MTQsImF1dGhvcml0aWVzIjpbIlNUQU5EQVJEX1VTRVIiXSwianRpIjoiYjA4YTI5NGQtNmFhMi00NmRlLWJkMzMtNzg5MWZhMTQ2MzJkIiwiY2xpZW50X2lkIjoic3ludGVsIiwiU0FJRCI6WyJXUFI0TVY3OUJGOTQzIl19.8MVNARVYV7hpzmRGOOS-pbj_aCMyhCtaO4OzafY1kOM\"^^<http://www.w3.org/2001/XMLSchema#string>"
}
]
(Notice how only the playerid
and token
variables are set. This makes it so that the ANSWER can fill in the other variables in its response bindings.)
ANSWER sends (I've omitted the handle request ID, and only pasted the bindingset here):
[
{
"deviceAddress": "\"WPR4KYJFNMBCC\"^^<http://www.w3.org/2001/XMLSchema#string>",
"appliances": "<https://www.example.org/appliances>",
"name": "\"natis\"^^<http://www.w3.org/2001/XMLSchema#string>",
"type": "\"FabricCare\"^^<http://www.w3.org/2001/XMLSchema#string>",
"brand": "\"Hotpoint\"^^<http://www.w3.org/2001/XMLSchema#string>",
"playerid": "\"xyz\"^^<http://www.w3.org/2001/XMLSchema#string>",
"token": "\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjIzMTMxLCJSb2xlTmFtZSI6IlNUQU5EQVJEX1VTRVIiLCJjb21wYW55SWQiOjAsIlVzZXJOYW1lIjoiRmVkZXJpY2FJbmRlcnN0IiwidXNlcl9uYW1lIjoiRkVERVJJQ0EuSU5ERVJTVEBHTUFJTC5DT00iLCJzY29wZSI6WyJ0cnVzdCIsInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE2NTcyMDQ2MTQsImF1dGhvcml0aWVzIjpbIlNUQU5EQVJEX1VTRVIiXSwianRpIjoiYjA4YTI5NGQtNmFhMi00NmRlLWJkMzMtNzg5MWZhMTQ2MzJkIiwiY2xpZW50X2lkIjoic3ludGVsIiwiU0FJRCI6WyJXUFI0TVY3OUJGOTQzIl19.8MVNARVYV7hpzmRGOOS-pbj_aCMyhCtaO4OzafY1kOM\"^^<http://www.w3.org/2001/XMLSchema#string>"
},
{
"deviceAddress": "\"WPR4MV79BF943\"^^<http://www.w3.org/2001/XMLSchema#string>",
"appliances": "<https://www.example.org/appliances>",
"name": "\"Lavatrice\"^^<http://www.w3.org/2001/XMLSchema#string>",
"type": "\"FabricCare\"^^<http://www.w3.org/2001/XMLSchema#string>",
"brand": "\"Hotpoint\"^^<http://www.w3.org/2001/XMLSchema#string>",
"playerid": "\"xyz\"^^<http://www.w3.org/2001/XMLSchema#string>",
"token": "\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOjIzMTMxLCJSb2xlTmFtZSI6IlNUQU5EQVJEX1VTRVIiLCJjb21wYW55SWQiOjAsIlVzZXJOYW1lIjoiRmVkZXJpY2FJbmRlcnN0IiwidXNlcl9uYW1lIjoiRkVERVJJQ0EuSU5ERVJTVEBHTUFJTC5DT00iLCJzY29wZSI6WyJ0cnVzdCIsInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE2NTcyMDQ2MTQsImF1dGhvcml0aWVzIjpbIlNUQU5EQVJEX1VTRVIiXSwianRpIjoiYjA4YTI5NGQtNmFhMi00NmRlLWJkMzMtNzg5MWZhMTQ2MzJkIiwiY2xpZW50X2lkIjoic3ludGVsIiwiU0FJRCI6WyJXUFI0TVY3OUJGOTQzIl19.8MVNARVYV7hpzmRGOOS-pbj_aCMyhCtaO4OzafY1kOM\"^^<http://www.w3.org/2001/XMLSchema#string>"
}
]
Notice how all bindings in the ANSWER binding set 'match' with the ASK binding.
In GitLab by @han.kruiger.tno.nl on Jul 26, 2022, 09:49
@facoelho Note that we can easily disable this validation on ke.interconnectproject.eu with a system variable. That's something worth considering.
In GitLab by @facoelho on Jul 26, 2022, 10:02
@han.kruiger.tno.nl I am running some tests with my test graph patterns and from our own services. I will come back here to share my findings and validate with you if I am picturing this right.
In fact turn this off is an option. The problem is that the cloud instance can used by everybody, it is not a pilot specific install, so enabling or disabling features will have a wide impact.
After collecting your feedback from my assessment, we'll consider if disabling the feature is an option.
In GitLab by @facoelho on Jul 26, 2022, 12:49
@han.kruiger.tno.nl After my tests and fixes I was able to make things working. Please provide me just one more confirmation. For the case of the pairs POST/REACT, if the REACT has an argument and result GP, the result GP must be a sub-set of the argument GP and indeed have at least one Binding matching the incoming BS that arrives from the POST, correct?
If this is the case, this does not require us to change the flag in the cloud deployment of the KE. However, I would recommend that you guys could send a clarification forwarding the email you sent notifying the KE update. Partners have few experience with these technologies so they would be better served with a code example on what needs to be matched in order for it to work.
In GitLab by @han.kruiger.tno.nl on Jul 26, 2022, 13:12
Good to hear!
For the case of the pairs POST/REACT, if the REACT has an argument and result GP, the result GP must be a sub-set of the argument GP and indeed have at least one Binding matching the incoming BS that arrives from the POST, correct?
This is almost correct. If the argument and result graph patterns share variables, then only those shared variables are checked.
For example, if this is the argument graph pattern (variables ?a
, ?b
, ?c
):
?a ex:example1 ?b .
?a ex:example2 ?c .
and this is the result graph pattern (variables ?a
, ?b
, ?d
):
?a ex:example1 ?b .
?a ex:example3 ?d .
and if the POST part sends this binding:
[
{
"a": "<something-a>",
"b": "<something-b>",
"c": "<something-c>"
}
]
then the REACT binding must be something like this:
[
{
"a": "<something-a>", // exactly this value MUST be here
"b": "<something-b>", // exactly this value MUST be here
"d": "<something-d>" // can be whatever, but must be here
}
]
So, the ?a
and ?b
variables must exactly match an incoming binding. The ?d
variable must be present (because it must be a complete answer) but may be set to anything.
If there isn't any overlap in the variables of the argument and result graph patterns, then this validation should have no effect.
I would recommend that you guys could send a clarification forwarding the email you sent notifying the KE update.
Good point. It was mentioned in the original e-mail, and I linked to a page with an example. But seeing the impact of this change, I will send an e-mail with a clarification.
In GitLab by @davide_micheletto_reply.whirlpool.com on Jul 27, 2022, 10:53
Very kind, now I was able to understand the problem and fix it with some tricks. Thank you!
In GitLab by @davide_micheletto_reply.whirlpool.com on Jul 25, 2022, 17:01
Hi all,
since you activated the binding validation on the KE, we encounter errors on all services. Here is an example:
GRAPHPATTERN
ASK - REQUEST
ANSWER - SEND
ASK - RESPONSE
How can we understand the cause of the error? Can you give us some suggestions?