fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

sh:ignoredProperties on sh:closed NodeShapes fails to handle @id and @type aliases #6

Closed aaj3f closed 1 year ago

aaj3f commented 1 year ago

When creating a closed node shape, if using sh:ignoreProperties to specify, for example, { "@id": "rdf:type" } as an allowed property, subsequent transactions with an @type are rejected with the error { :message "SHACL shape is closed, property: 200 is not an allowed." :data {:status 400, :error :db/shacl-validation } }

This is true even if @type is explicitly added in sh:ignoreProperties along with rdf:type

Creation Transaction 1

{
  "ledger": "issue/ignored-properties",
  "defaultContext": {
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "sh": "http://www.w3.org/ns/shacl#",
    "schema": "http://schema.org/",
    "skos": "http://www.w3.org/2008/05/skos#",
    "wiki": "https://www.wikidata.org/wiki/",
    "f": "https://ns.flur.ee/ledger#"
  },
  "txn": {
    "@type": [
      "sh:NodeShape"
    ],
    "sh:targetClass": {
      "id": "schema:Book"
    },
    "sh:name": "schema:Book",
    "sh:property": [
      {
        "sh:path": {
          "id": "schema:title"
        },
        "sh:datatype": {
          "id": "xsd:string"
        }
      }
    ],
    "sh:closed": true,
    "sh:ignoredProperties": [{"@id": "rdf:type"}]
  }
}

Failed transaction against schem:Book:

{
    "ledger": "issue/ignored-properties",
    "txn": {
        "txn": {
            "@type": "schema:Book",
            "schema:title": "The Picture of Dorian Gray"
        }
    }
}

Error message:

{
    "spec": "(spec-tools.core/spec {:spec clojure.core/string?, :type :string, :leaf? true})",
    "problems": [
        {
            "path": [],
            "pred": "clojure.core/string?",
            "val": {
                "error": "db/shacl-validation",
                "message": "SHACL shape is closed, property: 200 is not an allowed."
            },
            "via": [],
            "in": []
        }
    ],
    "type": "reitit.coercion/response-coercion",
    "coercion": "spec",
    "value": {
        "error": "db/shacl-validation",
        "message": "SHACL shape is closed, property: 200 is not an allowed."
    },
    "in": [
        "response",
        "body"
    ]
}
aaj3f commented 1 year ago

Related to Nexus issue: https://github.com/fluree/flhubee/issues/221

dpetran commented 1 year ago

This has been fixed already, I cannot reproduce that error with these steps anymore.