RDFLib / pySHACL

A Python validator for SHACL
Apache License 2.0
241 stars 63 forks source link

Message template substitutions for parameters of SPARQL-based Constraint Components fail when the value is not a Literal #199

Closed mgberg closed 10 months ago

mgberg commented 10 months ago

The code for substitution of parameters of SPARQL-based Constraint Components is: https://github.com/mgberg/pySHACL/blob/a0f5647a0f84f9bd6a57b627071d6dab2a1144e2/pyshacl/helper/sparql_query_helper.py#L122

If the parameter is not a Literal, then param_map[variable].value will raise an AttributeError. Instead, it should just use the string representation of the variable binding like is done here:

https://github.com/mgberg/pySHACL/blob/a0f5647a0f84f9bd6a57b627071d6dab2a1144e2/pyshacl/constraints/constraint_component.py#L309

I'll submit a PR shortly to fix this.