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

JSON-LD compaction error on catalog-request #4160

Open
arnoweiss opened this issue May 3, 2024 · 0 comments
Open

JSON-LD compaction error on catalog-request #4160

arnoweiss opened this issue May 3, 2024 · 0 comments
Assignees
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification

Comments

@arnoweiss
Copy link

Bug Report

Describe the Bug

Under very particular circumstances, a consumer's catalog-request fails if the provider has configured his assets in such a way that the JSON-LD compaction breaks.

Expected Behavior

HTTP 200 - serve the Provider's catalog.

Observed Behavior

HTTP 502

[
    {
        "message": "{\"@type\":\"dspace:CatalogError\",\"dspace:code\":\"401\",\"dspace:reason\":\"Unauthorized\",\"@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/\",\"dcat\":\"http://www.w3.org/ns/dcat#\",\"dct\":\"http://purl.org/dc/terms/\",\"odrl\":\"http://www.w3.org/ns/odrl/2/\",\"dspace\":\"https://w3id.org/dspace/v0.8/\"}}"](https://w3id.org/edc/v0.0.1/ns//%22,/%22edc/%22:/%22https://w3id.org/edc/v0.0.1/ns//%22,/%22tx/%22:/%22https://w3id.org/tractusx/v0.0.1/ns//%22,/%22tx-auth/%22:/%22https://w3id.org/tractusx/auth//%22,/%22cx-policy/%22:/%22https://w3id.org/catenax/policy//%22,/%22dcat/%22:/%22http://www.w3.org/ns/dcat#\%22,\%22dct\%22:\%22http://purl.org/dc/terms/\%22,\%22odrl\%22:\%22http://www.w3.org/ns/odrl/2/\%22,\%22dspace\%22:\%22https://w3id.org/dspace/v0.8/\%22%7D%7D%22),
        "type": "BadGateway",
        "path": null,
        "invalidValue": null
    }
]

Steps to Reproduce

  1. Provider-side: Create Asset via POST /v3/assets with payload. Note the missing binding of the dct prefix in the context.
{
  "@context": {
    "edc": "https://w3id.org/edc/v0.0.1/ns/"
  },
  "@id": "breakingAsset",
  "properties": {
    "dct:type": {"@id": "https://w3id.org/my-taxonomy#MyAssetType"}
  },
  "privateProperties": {
  },
  "dataAddress": {
    "@type": "DataAddress",
    "type": "HttpData",
    "baseUrl": "https://my-backend.url",
    "oauth2:tokenUrl": "https://my-auth.server/token",
    "oauth2:clientId": "myclient",
    "oauth2:clientSecretKey":"mykey",
    "type": "HttpData",
    "proxyMethod": "true",
    "proxyQueryParams": "true",
    "proxyPath": "true"
  }
}
  1. Provider-side: create contract-definition with arbitrary policy, allowing the consumer to satisfy the access policy.
  2. Consumer-side: query catalog

Context Information

Provider logs:

jakarta.ws.rs.InternalServerErrorException: Failed to compact JsonObject: When compacting an IRI would result in an IRI which could be confused with a compact IRI [code=IRI_CONFUSED_WITH_PREFIX].

The error is triggered here in the titanium json-ld lib. An issue with the same exception (though on a different endpoint) was fixed before, see #3172.

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

Possible Root Cause

The error is triggered by the property "dct:type": {"@id": "https://w3id.org/my-taxonomy#MyAssetType"} ONLY IF the @context in the POST /v3/assets request does not bind the dct namespace. dct:type is interpreted as an expanded, absolute URI and persisted properly. However, upon catalog-request the property is loaded from the database and titanium processes it according to the standard context of the EDC that includes dct as set here:

All prerequisites of the IRI compaction algorithm, step 9 are then true and an exception is thrown. The same issue would likely occur with all other EDC-registered prefixes (dcat, dspace, ...).

@github-actions github-actions bot added the triage all new issues awaiting classification label May 3, 2024
@ndr-brt ndr-brt added the bug_report Suspected bugs, awaiting triage label May 8, 2024
@mspiekermann mspiekermann modified the milestone: Milestone 16 May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_report Suspected bugs, awaiting triage triage all new issues awaiting classification
Projects
None yet
Development

No branches or pull requests

4 participants