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

[contract definition] Error when retrieving a single contract definition #3137

Closed
AhmedGrati opened this issue Jun 1, 2023 · 12 comments
Closed
Labels
enhancement New feature or request good first issue Good for newcomers stale Open for x days with no activity

Comments

@AhmedGrati
Copy link

Bug Report

Describe the Bug

When trying to fetch a contract definition by ID, the edc:criteria is returned as an object, while It should be an array of objects.

Expected Behavior

When getting a contract definition by ID, I expect this object:

{
  "@id": "contract",
  "@type": "edc:ContractDefinition",
  "edc:accessPolicyId": "example-access-policy-id",
  "edc:contractPolicyId": "example-contract-policy-id",
  "edc:criteria": [{
    "@type": "edc:CriterionDto",
    "edc:operandLeft": "edc.asset",
    "edc:operandRight": "test",
    "edc:operator": "equals"
  }],
  "@context": {
    "dct": "https://purl.org/dc/terms/",
    "edc": "https://w3id.org/edc/v0.0.1/ns/",
    "dcat": "https://www.w3.org/ns/dcat/",
    "odrl": "http://www.w3.org/ns/odrl/2/",
    "dspace": "https://w3id.org/dspace/v0.8/"
  }
}

Observed Behavior

In reality, the EDC connector is returning an edc:criteria as a single object. e.g:

{
  "@id": "contract",
  "@type": "edc:ContractDefinition",
  "edc:accessPolicyId": "example-access-policy-id",
  "edc:contractPolicyId": "example-contract-policy-id",
  "edc:criteria": {
    "@type": "edc:CriterionDto",
    "edc:operandLeft": "edc.asset",
    "edc:operandRight": "test",
    "edc:operator": "equals"
  },
  "@context": {
    "dct": "https://purl.org/dc/terms/",
    "edc": "https://w3id.org/edc/v0.0.1/ns/",
    "dcat": "https://www.w3.org/ns/dcat/",
    "odrl": "http://www.w3.org/ns/odrl/2/",
    "dspace": "https://w3id.org/dspace/v0.8/"
  }
}

Steps to Reproduce

Steps to reproduce the behavior:

  1. Create a contract definition with the following object as the body of the request:
{
  "@id": "contract",
  "accessPolicyId": "example-access-policy-id",
  "contractPolicyId": "example-contract-policy-id",
  "@context": {},
  "criteria": [
    {
      "operandLeft": "edc.asset",
      "operandRight": "test",
      "operator": "equals"
    }
  ]
}
  1. Fetch that specific contract definition, using the route /contractdefinitions/contract, and you should see the following response:
{
  "@id": "contract",
  "@type": "edc:ContractDefinition",
  "edc:accessPolicyId": "example-access-policy-id",
  "edc:contractPolicyId": "example-contract-policy-id",
  "edc:criteria": {
    "@type": "edc:CriterionDto",
    "edc:operandLeft": "edc.asset",
    "edc:operandRight": "test",
    "edc:operator": "equals"
  },
  "@context": {
    "dct": "https://purl.org/dc/terms/",
    "edc": "https://w3id.org/edc/v0.0.1/ns/",
    "dcat": "https://www.w3.org/ns/dcat/",
    "odrl": "http://www.w3.org/ns/odrl/2/",
    "dspace": "https://w3id.org/dspace/v0.8/"
  }
}

Context Information

N/A

Detailed Description

The creation of contract definition
Screen Shot 2023-06-01 at 1 30 07 PM

The fetching of the previously created contract definition
Screen Shot 2023-06-01 at 1 30 39 PM

When I create a contract definition with multiple criteria, the response of the GET request of a single contract definition, would have an array of objects in the edc:criteria, which is the desired response. Therefore there's an inconsistency in the API response when trying to GET a single contract definition.

Possible Implementation

N/A.

@AhmedGrati AhmedGrati added the bug Something isn't working label Jun 1, 2023
@github-actions
Copy link

github-actions bot commented Jun 1, 2023

Thanks for your contribution 🔥 We will take a look asap 🚀

@wolf4ood
Copy link
Contributor

wolf4ood commented Jun 1, 2023

Hi @AhmedGrati

this happens because of the compaction process as stated in the json-ld spec. The default configuration of the option compactArrays is true in the spec and in the library that we use. Unfortunately it's not possible yet to override that configuration. I would label this issue as enhancement and make it configurable.

In case you are interested in contributing this is the entry point for the jsonld extension. and here where the compact happens.

Thanks

@wolf4ood wolf4ood added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working labels Jun 1, 2023
@jimmarino
Copy link
Contributor

I'm not sure we want to make this configurable. We probably should support one way or the other.

@SamantaTarun
Copy link

I'd like to work on it.

@wolf4ood
Copy link
Contributor

wolf4ood commented Jun 1, 2023

If we want to have a fixed solution i would prefer the not compressed one always :)

@jimmarino
Copy link
Contributor

jimmarino commented Jun 1, 2023

I'd like to work on it.

Sorry misread! That would be great!

@ndr-brt
Copy link
Member

ndr-brt commented Jun 7, 2023

Another advice could be to always expand json-ld before evaluating it, because as a client you cannot take for granted a specific server compaction configuration.

@github-actions
Copy link

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

@github-actions
Copy link

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

1 similar comment
@github-actions
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 Jun 29, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2023
@AhmedGrati
Copy link
Author

@ndr-brt any update on this?

@ndr-brt
Copy link
Member

ndr-brt commented Jul 13, 2023

nobody had the time to do this, we're eventually waiting for community contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers stale Open for x days with no activity
Projects
None yet
Development

No branches or pull requests

5 participants