Skip to content

f:Policy compact IRI error throws but 200 response returned #468

Closed

Description

@aaj3f

Description

Slack discussion here

When the "f": "https://ns.flur.ee/ledger#" term is not defined by a user in their own context or defaultContext, an error gets thrown when using opts: { did, role }: clojure.lang.ExceptionInfo: Invalid compact-iri: :f/Policy {:status 400, :error :json-ld/invalid-iri}

However, the http-api-gateway instance still returns a 200 with a [] response body.

The issue can be recreated via the following (which mimics the test example here):

  1. Create Ledger (/create)
{
    "ledger": "policy-opts-ledger",
    "defaultContext": ["", {
        "id": "@id",
        "type": "@type",
        "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/",
        "ex": "http://example.org/"
    }],
    "txn": {
        "id": "ex:create-test",
        "type": "ex:test",
        "ex:name": "create-endpoint-test"
    }
}
  1. Add Data (/transact)
{
    "ledger": "policy-opts-ledger",
    "txn": [
        {
            "id": "ex:alice",
            "type": "ex:User",
            "ex:secret": "alice's secret"
        },
        {
            "id": "ex:bob",
            "type": "ex:User",
            "ex:secret": "bob's secret"
        },
        {
            "id": "ex:UserPolicy",
            "type": [
                "f:Policy"
            ],
            "f:targetClass": {
                "id": "ex:User"
            },
            "f:allow": [
                {
                    "id": "ex:globalViewAllow",
                    "f:targetRole": {
                        "id": "ex:userRole"
                    },
                    "f:action": [
                        {
                            "id": "f:view"
                        }
                    ]
                }
            ],
            "f:property": [
                {
                    "f:path": {
                        "id": "ex:secret"
                    },
                    "f:allow": [
                        {
                            "id": "ex:secretsRule",
                            "f:targetRole": {
                                "id": "ex:userRole"
                            },
                            "f:action": [
                                {
                                    "id": "f:view"
                                },
                                {
                                    "id": "f:modify"
                                }
                            ],
                            "f:equals": {
                                "@list": [
                                    {
                                        "id": "f:$identity"
                                    },
                                    {
                                        "id": "ex:user"
                                    }
                                ]
                            }
                        }
                    ]
                }
            ]
        },
        {
            "id": "did:fluree:Tf6i5oh2ssYNRpxxUM2zea1Yo7x4uRqyTeU",
            "ex:user": {
                "id": "ex:alice"
            },
            "f:role": {
                "id": "ex:userRole"
            }
        }
    ]
}
  1. Query as Alice (/query)
{
    "ledger": "policy-opts-ledger",
    "query": {
        "where": [
            ["?s", "rdf:type", "ex:User"]
        ],
        "select": {
            "?s": ["*"]
        },
        "opts": {
            "role": "ex:userRole",
            "did": "did:fluree:Tf6i5oh2ssYNRpxxUM2zea1Yo7x4uRqyTeU"
        }
    }
}

Activity

  1. added
    bug
    on Apr 19, 2023
  2. added this to the 3.0.0-alpha3 milestone on Apr 19, 2023
  3. self-assigned this
    on May 9, 2023
  4. cap10morgan commented on May 9, 2023

    @cap10morgan
    Contributor

    Transferred this issue to db repo as I think most or all of the work needs to happen in there.

  5. cap10morgan commented on May 10, 2023

    @cap10morgan
    Contributor

    @aaj3f I fixed what was likely the entire issue here in db, but can you test in http-api-gateway again to confirm? I've updated it to point at the latest db main HEAD commit.

    I should probably add a test like this to the http-api-gateway repo too, but I need to rethink our testing strategy a bit before we end up with a copy of every test in both repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions