Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Policy model rightOperand can't handle list of literal values #4525

Closed
gkirtzou opened this issue Oct 2, 2024 · 5 comments
Closed

Policy model rightOperand can't handle list of literal values #4525

gkirtzou opened this issue Oct 2, 2024 · 5 comments
Labels
suggestion feature ideas

Comments

@gkirtzou
Copy link

gkirtzou commented Oct 2, 2024

Bug Report

Describe the Bug

Create a policy that contains a list of literals as rightOperand in a constraint as the following:

{
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "dcat": "http://www.w3.org/ns/dcat#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "adms": "http://www.w3.org/ns/adms#",
        "dcmitype": "http://purl.org/dc/dcmitype/",
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "dct": "http://purl.org/dc/terms/",
        "odrl": "http://www.w3.org/ns/odrl/2/",
        "owl": "http://www.w3.org/2002/07/owl#",
        "cc": "http://creativecommons.org/ns#",
        "dalicc": "https://dalicc.net/ns#",
        "dalicclib": "https://dalicc.net/licenselibrary/",
        "osl": "http://opensource.org/licenses/",
        "prov": "http://www.w3.org/ns/prov#",
        "spdx": "http://spdx.org/rdf/terms#",
        "example": "http://www.example.com/"
    },
    "policy": {
        "@type": "odrl:Set",
        "dct:description": {
            "@language": "en",
            "@value":"Connector Restricted Usage"
        },
        "dct:title": {
            "@language": "en",
            "@value": "Connector Restricted Usage"
        },
        "odrl:permission": [
            {
                "@type": "odrl:Permission",
                "odrl:action": {
                    "@id": "odrl:use"
                },
                "odrl:constraint" : {
                    "@type" : "odrl:Constraint",
                    "odrl:rightOperand" : ["https://www.connector1.com", "https://www.connector2.com"],
                    "odrl:leftOperand" : {
                      "@id" : "odrl:systemDevice"
                    },
                    "odrl:operator" : {
                      "@id" : "odrl:isAnyOf"
                    }
                }
            }
        ],
        "odrl:obligation": null,
        "odrl:prohibition": null
    }
}

Expected Behavior

Retrieve the policy, where the odrl:rightOperand is a list of the provided values, similar to the one provided when creating the policy.

Observed Behavior

When retrieving the above create policy we get the following. Please note how odrl:rightOperand is returned

{
    "@id": "feea67e9-784a-4f86-83aa-02b17e95bdb1",
    "@type": "PolicyDefinition",
    "createdAt": 1727873504339,
    "policy": {
        "@id": "0614de32-3202-4bd0-8ef2-1031fa29a95d",
        "@type": "odrl:Set",
        "odrl:permission": {
            "odrl:action": {
                "@id": "odrl:use"
            },
            "odrl:constraint": {
                "odrl:leftOperand": {
                    "@id": "odrl:systemDevice"
                },
                "odrl:operator": {
                    "@id": "odrl:isAnyOf"
                },
                "odrl:rightOperand": "[{@value={valueType=STRING, chars=https://www.connector1.com, string=https://www.connector1.com}}, {@value={valueType=STRING, chars=https://www.connector2.com, string=https://www.connector2.com}}]"
            }
        },
        "odrl:prohibition": [],
        "odrl:obligation": []
    },
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "lds": "https://lds.eu/",
        "omtd": "http://w3id.org/meta-share/omtd-share/",
        "odrl": "http://www.w3.org/ns/odrl/2/",
        "ms": "http://w3id.org/meta-share/meta-share/",
        "euvoc_auth": "http://publications.europa.eu/resource/authority/",
        "owl": "http://www.w3.org/2002/07/owl#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "dcat": "http://www.w3.org/ns/dcat#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "adms": "http://www.w3.org/ns/adms#",
        "loc": "http://id.loc.gov/vocabulary/iso639-1/",
        "dcmitype": "http://purl.org/dc/dcmitype/",
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "iana": "http://www.iana.org/assignments/media-types/application/",
        "dct": "http://purl.org/dc/terms/",
        "schema": "https://schema.org/"
    }
}

Context Information

EDC seems to support the representation of set operators. However, when a set operator is used, ODRL models expects odrl:rightOperant to be

"for set-based operators; list of literals, or list of IRIs [rfc3987], or list of RightOperands;"

(from https://www.w3.org/TR/odrl-model/#constraint) .

The error probably comes from EDC implementation of the Expressions as a single literal value.
Any plans to support list of literal values, in order to support set operators representation? Or is the above policy representation wrong and EDC expect the input somehow different?

Thanks is advance

@github-actions github-actions bot added the triage all new issues awaiting classification label Oct 2, 2024
@jimmarino jimmarino added the suggestion feature ideas label Oct 2, 2024
@jimmarino
Copy link
Contributor

Complex types are not currently supported. The core policy evaluator can handle complex types, but a number of considerations would need to be taken into account. The most important is that JSON-LD expands properties into array structures, so it is not possible to reliably determine if a type is a scalar value or an array of types.

The code that would need to be modified is JsonObjectToConstraintTransformer.extractComplexValue(JsonValue root). Leaving aside the JSON-LD issue, the code would need to return the deserialized Map, List, or scalar values.

This is a feature that requires investigation, and barring a proposal and subsequent PR, I don't think will get priority.

@gkirtzou
Copy link
Author

gkirtzou commented Oct 3, 2024

Thanks for the clarification and I hope to get resolved at some point, as it is limiting the possible policies that a dataspace can use, if we cannot represent them with EDC to be used in order to make an offer.

You mentioned that the core policy evaluator can handle complex types, meaning lists of literals like the one above? I haven't checked the policy evaluator, my initial focus was to check what policies I could represent within EDC, as my understanding was that the policy evaluator evaluates the policy that comes from a specific contract, which are based policies (aka odrl:sets) that are stored within EDC and have been used in offers. Do I miss something?

@jimmarino
Copy link
Contributor

Look at the method I pointed to in my previous post. The best way to prioritize this is to submit a proposal and subsequent PR.

@jimmarino jimmarino removed the triage all new issues awaiting classification label Oct 3, 2024
Copy link

This issue is stale because it has been open for 14 days with no activity.

@github-actions github-actions bot added the stale Open for x days with no activity label Oct 18, 2024
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
@github-actions github-actions bot removed the stale Open for x days with no activity label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion feature ideas
Projects
None yet
Development

No branches or pull requests

2 participants