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

No persistence of nested odrl:leftOperand.@id property in /v2/policydefinitions API #4179

Closed
arnoweiss opened this issue May 14, 2024 · 1 comment · Fixed by #4185
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@arnoweiss
Copy link

arnoweiss commented May 14, 2024

Bug Report

Describe the Bug

The /v2/policydefinitions API does not persist resources/objects with @id in the leftOperand property.

Steps to Reproduce

1. Create policy

POST /v2/policydefinitions with

{
  "@context": [
    {
      "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "http://www.w3.org/ns/odrl.jsonld"
  ],
  "@id": "left-op-scen-0",
  "policy": {
    "@type": "http://www.w3.org/ns/odrl/2/Set",
    "permission": [
      {
        "action": "use",
        "odrl:constraint": {
          "leftOperand": {
            "@id": "https://w3id.org/catenax/policy/FrameworkAgreement"
          },
          "odrl:operator": {
            "@id": "odrl:eq"
          },
          "odrl:rightOperand": "traceability:3.0"
        }
      }
    ]
  }
}

returns HTTP 200.

{
    "@type": "IdResponse",
    "@id": "left-op-scen-0",
    "createdAt": 1715705166810,
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "tx": "https://w3id.org/tractusx/v0.0.1/ns/",
        "tx-auth": "https://w3id.org/tractusx/auth/",
        "cx-policy": "https://w3id.org/catenax/policy/",
        "odrl": "http://www.w3.org/ns/odrl/2/"
    }
}

2. Retrieve resource

GET /v2/policydefinitions/left-op-scen-0

Expected Behavior

Though the compacted notation may differ, the content in the constraint property should be equal in expanded form.

Observed Behavior

Step 2 returns:

{
    "@id": "left-op-scen-0",
    "@type": "PolicyDefinition",
    "createdAt": 1715705166810,
    "policy": {
        "@id": "177d7dbf-6ea8-4b7c-aa3d-3576dd4596c0",
        "@type": "odrl:Set",
        "odrl:permission": {
            "odrl:action": {
                "odrl:type": "http://www.w3.org/ns/odrl/2/use"
            },
            "odrl:constraint": {
                "odrl:leftOperand": "https://w3id.org/catenax/policy/FrameworkAgreement",
                "odrl:operator": {
                    "@id": "odrl:eq"
                },
                "odrl:rightOperand": "traceability:3.0"
            }
        },
        "odrl:prohibition": [],
        "odrl:obligation": []
    },
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "tx": "https://w3id.org/tractusx/v0.0.1/ns/",
        "tx-auth": "https://w3id.org/tractusx/auth/",
        "cx-policy": "https://w3id.org/catenax/policy/",
        "odrl": "http://www.w3.org/ns/odrl/2/"
    }
}

Note that the leftOperand holds a string unwrapped from the object from step 1. Since the returned @context object doesn't include the odrl-context but just the odrl-term/prefix, this expands to a different payload in json-ld, holding a literal (@value) instead a resource (@id).

Context Information

Given the context from call 1, titanium coerces the payload into an object holding @id. It also allows to use

  • "leftOperand": "cx-policy:FrameworkAgreement",
  • "leftOperand": "https://w3id.org/catenax/policy/FrameworkAgreement",
  • "leftOperand": {"@id":"cx-policy:FrameworkAgreement"},
  • "leftOperand": {"@id":"https://w3id.org/catenax/policy/FrameworkAgreement"},

however NOT (yielding an object with @value):

  • "odrl:leftOperand": "cx-policy:FrameworkAgreement",
  • "odrl:leftOperand": "https://w3id.org/catenax/policy/FrameworkAgreement",

That makes me guess the issue may lie somewhere in the persistence.

Setup: eclipse-edc 0.6.2 (as part of tractusx-edc 0.7.0).

@github-actions github-actions bot added the triage all new issues awaiting classification label May 14, 2024
@mspiekermann mspiekermann added the bug Something isn't working label May 15, 2024
@mspiekermann mspiekermann added this to the Milestone 16 milestone May 15, 2024
@wolf4ood wolf4ood self-assigned this May 15, 2024
@wolf4ood
Copy link
Contributor

Hi @arnoweiss

thanks for raising this, i think this is a serialization issue and not at persistence level

Since the leftOperand is an id at odrl level the output should reflect this when serialized with odrl:prefix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants