eclipse-tractusx / tutorial-resources

Apache License 2.0
11 stars 23 forks source link

Tutorial's EDR request fails - `Policy in the contract agreement is not equal to the one in the contract offer` #277

Closed anschl closed 6 months ago

anschl commented 6 months ago

Hi everyone, I'm stuck on the first step of the EDR tutorial.

What I did:

  1. Initialize the cluster
  2. Request the catalog:
    curl --location 'https://cx.thebatterypass.io/bob/management/v2/catalog/request' \
    --header 'Content-Type: application/json' \
    --header 'X-Api-Key: password' \
    --data-raw '{
    "@context": {
    "edc": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "@type": "CatalogRequest",
    "counterPartyAddress": "http://alice-controlplane:8084/api/v1/dsp",
    "protocol": "dataspace-protocol-http",
    "querySpec": {
    "offset": 0,
    "limit": 50
    }
    }'

    Returns:

    {
    "@id": "d798514d-5890-4e7e-a00d-5be1e52e13a3",
    "@type": "dcat:Catalog",
    "dcat:dataset": [
    {
      "@id": "1",
      "@type": "dcat:Dataset",
      "odrl:hasPolicy": {
        "@id": "MQ==:MQ==:MTZhOGEyZTgtY2QwNy00N2MwLTkxOGItZDU1M2ZiNjhhMzk2",
        "@type": "odrl:Set",
        "odrl:permission": {
          "odrl:target": "1",
          "odrl:action": {
            "odrl:type": "USE"
          },
          "odrl:constraint": {
            "odrl:or": {
              "odrl:leftOperand": "BusinessPartnerNumber",
              "odrl:operator": {
                "@id": "odrl:eq"
              },
              "odrl:rightOperand": "BPNL000000000002"
            }
          }
        },
        "odrl:prohibition": [],
        "odrl:obligation": [],
        "odrl:target": {
          "@id": "1"
        }
      },
      "dcat:distribution": [
        {
          "@type": "dcat:Distribution",
          "dct:format": {
            "@id": "HttpProxy-PUSH"
          },
          "dcat:accessService": "12231d1d-66df-410a-bf62-f6f44fe747ea"
        },
        {
          "@type": "dcat:Distribution",
          "dct:format": {
            "@id": "AzureStorage-PUSH"
          },
          "dcat:accessService": "12231d1d-66df-410a-bf62-f6f44fe747ea"
        },
        {
          "@type": "dcat:Distribution",
          "dct:format": {
            "@id": "HttpData-PULL"
          },
          "dcat:accessService": "12231d1d-66df-410a-bf62-f6f44fe747ea"
        },
        {
          "@type": "dcat:Distribution",
          "dct:format": {
            "@id": "AmazonS3-PUSH"
          },
          "dcat:accessService": "12231d1d-66df-410a-bf62-f6f44fe747ea"
        }
      ],
      "description": "Product EDC Demo Asset 1",
      "id": "1"
    },
    // ...
  3. Copy the @id value in dcat:dataset[0].odrl:hasPolicy.@id and replace it in the tutorial's request
  4. Send that request. It returns:
    {
    "@type": "IdResponse",
    "@id": "b8e10d8d-750c-4256-8eb6-d74e964dc6ca",
    "createdAt": 1710328534223,
    "@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/",
    "odrl": "http://www.w3.org/ns/odrl/2/"
    }
    }
  5. Check the negotiation status with http://localhost/bob/management/v2/contractnegotiations/b8e10d8d-750c-4256-8eb6-d74e964dc6ca:
    {
    "@type": "ContractNegotiation",
    "@id": "b8e10d8d-750c-4256-8eb6-d74e964dc6ca",
    "type": "CONSUMER",
    "protocol": "dataspace-protocol-http",
    "state": "REQUESTED",
    "counterPartyId": "BPNL000000000001",
    "counterPartyAddress": "http://alice-controlplane:8084/api/v1/dsp",
    "callbackAddresses": {
    "@type": "CallbackAddress",
    "transactional": true,
    "uri": "local://adapter",
    "events": [
      "contract.negotiation",
      "transfer.process"
    ]
    },
    "createdAt": 1710328534223,
    "@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/",
    "odrl": "http://www.w3.org/ns/odrl/2/"
    }
    }
  6. Check the logs with kubectl logs -f bob-tractusx-connector-controlplane-786979ccc6-kds9r:
    DEBUG 2024-03-13T11:15:34.225121079 [ConsumerContractNegotiationManagerImpl] ContractNegotiation b8e10d8d-750c-4256-8eb6-d74e964dc6ca is now in state INITIAL
    DEBUG 2024-03-13T11:15:34.373799766 [ConsumerContractNegotiationManagerImpl] ContractNegotiation b8e10d8d-750c-4256-8eb6-d74e964dc6ca is now in state REQUESTING
    DEBUG 2024-03-13T11:15:34.377960797 ContractNegotiation: ID b8e10d8d-750c-4256-8eb6-d74e964dc6ca. [Consumer] send request
    DEBUG 2024-03-13T11:15:34.674880897 ContractNegotiation: ID b8e10d8d-750c-4256-8eb6-d74e964dc6ca. [Consumer] send request
    DEBUG 2024-03-13T11:15:34.679129193 [ConsumerContractNegotiationManagerImpl] ContractNegotiation b8e10d8d-750c-4256-8eb6-d74e964dc6ca is now in state REQUESTED
    DEBUG 2024-03-13T11:15:34.918593095 DSP: Incoming ContractAgreementMessage for class org.eclipse.edc.connector.contract.spi.types.negotiation.ContractNegotiation process: b8e10d8d-750c-4256-8eb6-d74e964dc6ca
    DEBUG 2024-03-13T11:15:35.038910263 [Consumer] Contract agreement received. Validation failed: Policy in the contract agreement is not equal to the one in the contract offer
    DEBUG 2024-03-13T11:15:35.040097309 DSP: Service call failed: Contract agreement received. Validation failed: Policy in the contract agreement is not equal to the one in the contract offer

It says Policy in the contract agreement is not equal to the one in the contract offer so I compared the policy in step 2 with the one in step 3. There is a difference - the definition from step 2 says "odrl:target": {"@id": "1"} and the request has "odrl:target": "1". However, even after requesting the verbose variant it still throws the same error.

Did I do something wrong? Do you need more information? Thank you for your time.

hemantxpatel commented 6 months ago

Hi @anschl , I tried reproducing it but I couldn't. Could you please run this command and paste the output. It justs prints the docker images which are currently running in the pods.

 kubectl get pods -o jsonpath='{range .items[*]}{"\n"}{range .spec.containers[*]}{.image}{end}{end}'

For me, the output of the above command looks like this.

minio/minio:RELEASE.2022-03-17T06-34-49Z
tractusx/edc-controlplane-postgresql-hashicorp-vault:0.6.0
tractusx/edc-dataplane-hashicorp-vault:0.6.0
hashicorp/vault:1.10.3
mcr.microsoft.com/azure-storage/azurite
minio/minio:RELEASE.2022-03-17T06-34-49Z
tractusx/edc-controlplane-postgresql-hashicorp-vault:0.6.0
tractusx/edc-dataplane-hashicorp-vault:0.6.0
hashicorp/vault:1.10.3
quay.io/keycloak/keycloak:21.1
tractusx/managed-identity-wallet:main
postgres:15.3-alpine3.18

I am suspecting, you are running EDC with latest version tractusx/edc-controlplane-postgresql-hashicorp-vault:latest (missing latest tag also indicates it is latest). These tutorials might not work with latest EDC snapshot versions and it will be updated once EDC has a new release available.

anschl commented 6 months ago

Thanks! This helped - I don't encounter the error anymore.