Skip to content

Troubleshooting ​

Start with the rewritten query ​

Almost every question about what a user does or does not see is answered by the query that reaches the store:

sh
sparql-guard rewrite --policies policies.ttl --agent <iri> --group <name> query.rq

or, with "explain": true, send the same request to /sparql/explain with the user's own credentials. The response also lists the agent, the groups and the policies that matched.

Errors ​

StatusMessageCause and fix
401Authentication requiredNo credentials, and auth.anonymous is off.
401Invalid API keyThe key does not match any sha256 in auth.apiKeys. Hash it again with sparql-guard hash-key.
403No access policy applies to youNo sg:Policy matches the agent or its groups. Check the agent IRI and groups in the explain output.
403SPARQL Update is not allowed …The proxy is read-only.
403SERVICE (federated queries) is not allowed …Run federated queries against the endpoints directly.
403Property paths over the hidden property … are not allowedWrite the path out as separate triple patterns, or drop the hidden property.
400Cannot parse query: …Not valid SPARQL 1.1. Vendor extensions (Virtuoso DEFINE, …) are not supported.
400Transitive property paths (* and +) are not allowed under row-level policies …See below.
400Negated property sets are not allowed when properties are hiddenList the predicates you want instead of !(…).
400FROM / FROM NAMED are not supported under row-level policies; use GRAPH insteadThe policy uses sg:readAllGraphs together with row-level rules. Use GRAPH <…> { }, or list the graphs with sg:readGraph.
400Variables starting with ?__sg_ are reservedRename the variable.
502network error textThe upstream store is unreachable or timed out (timeoutMs).

Any other status, such as a 400 with a store-specific message, comes from the store itself.

Policy files that do not load ​

At startup the error is printed and the process exits. On reload, the error is logged and the previous policies stay active:

text
Policy reload failed, keeping previous policies: closed on shape <…> is not supported by sparql-guard
MessageFix
Cannot parse policies.ttl: …Turtle syntax error; the message has the line number.
… is not supported by sparql-guardThe shape uses a SHACL feature outside the supported subset.
Policy … applies to nobodyAdd sg:agent or sg:group.
Recursive shape reference …A shape refers to itself through sh:node, sh:and, …
sg:hideProperties shape … needs sh:property entries with a plain IRI sh:pathOnly plain predicates can be hidden.
Cardinality … is too largesh:minCount / sh:maxCount above 8.

"A user sees too little" ​

  • Restrictions add up. If the user is in several groups, every sg:visibleIf of every matching policy applies. The explain output lists the matched policies.
  • Hidden references. With sg:hideReferences on (the default), a triple whose object is hidden disappears, so ?x ex:manager ?m returns nothing if the manager is hidden. Use OPTIONAL for links that may point to hidden resources, or set sg:hideReferences false.
  • Shape semantics. sh:hasValue requires the value to be present; sh:in requires every value to be in the list. A resource without the property conforms to sh:in but not to sh:hasValue.
  • Default graph. With sg:readAllGraphs, a query without GRAPH sees the store's default graph, which may be empty. See Triple stores.

"A user sees too much" ​

  • Check whether a policy with sg:readAllGraphs or sg:agent sg:Anyone also matches.
  • Check that the store respects FROM; see Triple stores.
  • Resources that are not a target of any shape are never hidden. Check that the targets match the data: the class IRI, and that the rdf:type triple and any rdfs:subClassOf triples are in a graph the policy grants. Checks can't see graphs the caller can't read.

Slow queries ​

See Performance. In short: fewer and more specific shapes, graphSpanningChecks: false when a resource's data lives in one graph, and graph-only policies for users who do not need row-level rules.

Released under the Apache-2.0 license.