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

management API : Cannot retrieve asset after updating its properties #3172

Closed
NabilHouidi opened this issue Jun 12, 2023 · 4 comments · Fixed by #3192
Closed

management API : Cannot retrieve asset after updating its properties #3172

NabilHouidi opened this issue Jun 12, 2023 · 4 comments · Fixed by #3192
Assignees
Labels
bug Something isn't working

Comments

@NabilHouidi
Copy link

Bug Report

Describe the Bug

Updating an asset's properties causes a crash when trying GET on /assets/{id} later

Expected Behavior

The asset properties are updated and can be accessed

Observed Behavior

  • 204 response on PUT /assets
  • 500 error when trying to GET the asset's data
  • Asset not in list when running GET /assets/request

Steps to Reproduce

  1. Create an asset using this payload
{
  "@context": {
    "edc": "https://w3id.org/edc/v0.0.1/ns/"
  },
  "@type": "AssetEntryDto",
  "asset": {
    "@id": "test-id",
    "edc:properties": {
      "name": "asset-name",
      "description": "asset-description",
      "version": "0.0.1",
      "contenttype": "application/json"
    }
  },
  "dataAddress": {
    "type": "HttpData",
    "baseUrl": "http://hello.example.com"
  }
}

Response: 200

{
  "@type": "edc:IdResponseDto",
  "@id": "test-id",
  "edc:createdAt": 1686604479160,
  "@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/"
  }
}
  1. Update the assets' properties : PUT /assets with this payload:
{
  "@id": "test-id",
  "edc:properties": {
      "edc:id": "test-id",
      "edc:name": "asset-name-updated-321",
      "edc:description": "asset-description-updated",
      "edc:version": "0.0.2",
      "edc:contenttype": "application/json"
    },
  "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/"
  }
}

Response: 204
3. Try GET /assets/test-id
Response: 500

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
    <title>Error 500 Internal Server Error</title>
  </head>
  <body><h2>HTTP ERROR 500 Internal Server Error</h2>
    <table>
      <tr><th>URI:</th><td>/management/v2/assets/test-id</td></tr>
      <tr><th>STATUS:</th><td>500</td></tr>
      <tr><th>MESSAGE:</th><td>Internal Server Error</td></tr>
      <tr><th>SERVLET:</th><td>EDC-management</td></tr>
    </table>
    <hr /><a href="https://eclipse.org/jetty">Powered by Jetty:// 11.0.15</a><hr />

  </body>
</html>

Context Information

  • Version: 0.1.0 (milestone 9)

Detailed Description

Logs:

 WARNING 2023-06-12T21:17:01.405516919 Error compacting JSON-LD structure
 JsonLdError[code=When compacting an IRI would result in an IRI which could be confused with a compact IRI [code=IRI_CONFUSED_WITH_PREFIX]., message=When compacting an IRI would result in an IRI which could be confused with a compact IRI [code=IRI_CONFUSED_WITH_PREFIX].]
 	at com.apicatalog.jsonld.compaction.UriCompaction.compact(UriCompaction.java:543)
 	at com.apicatalog.jsonld.compaction.Compaction.compact(Compaction.java:444)
 	at com.apicatalog.jsonld.compaction.Compaction.compact(Compaction.java:498)
 	at com.apicatalog.jsonld.compaction.Compaction.compact(Compaction.java:113)
 	at com.apicatalog.jsonld.compaction.Compaction.compact(Compaction.java:83)
 	at com.apicatalog.jsonld.processor.CompactionProcessor.compact(CompactionProcessor.java:133)
 	at com.apicatalog.jsonld.api.CompactionApi.get(CompactionApi.java:172)
 	at org.eclipse.edc.jsonld.TitaniumJsonLd.compact(TitaniumJsonLd.java:87)
 	at org.eclipse.edc.spi.result.AbstractResult.compose(AbstractResult.java:193)
 	at org.eclipse.edc.connector.api.management.asset.AssetNewApiController.getAsset(AssetNewApiController.java:118)
 	at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
 	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
 	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
 	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
 	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:240)
 	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
 	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
 	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
 	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
 	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
 	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
 	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
 	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
 	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
 	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
 	at org.eclipse.jetty.server.Server.handle(Server.java:563)
 	at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
 	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
 	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
 	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
 	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
 	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
 	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:416)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:140)
 	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
 	at java.base/java.lang.Thread.run(Thread.java:833)
 SEVERE 2023-06-12T21:17:01.417971086 JerseyExtension: Unexpected exception caught
 org.eclipse.edc.spi.EdcException: When compacting an IRI would result in an IRI which could be confused with a compact IRI [code=IRI_CONFUSED_WITH_PREFIX].
 	at org.eclipse.edc.connector.api.management.asset.AssetNewApiController.lambda$getAsset$8(AssetNewApiController.java:119)
 	at org.eclipse.edc.spi.result.AbstractResult.orElseThrow(AbstractResult.java:126)
 	at org.eclipse.edc.connector.api.management.asset.AssetNewApiController.getAsset(AssetNewApiController.java:119)
 	at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
 	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
 	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
 	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
 	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
 	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
 	at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
 	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
 	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:240)
 	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
 	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
 	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
 	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
 	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
 	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
 	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
 	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
 	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
 	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
 	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
 	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:192)
 	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
 	at org.eclipse.jetty.server.Server.handle(Server.java:563)
 	at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
 	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
 	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
 	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
 	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
 	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
 	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:416)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)
 	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:140)
 	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
 	at java.base/java.lang.Thread.run(Thread.java:833)

Possible Implementation

No Idea

@saschaisele-zf
Copy link
Contributor

Hello, thank you for the submission.
While looking over it, I noticed, that your update payload might be responsible for the JSON-LD related crash.

{
  "@id": "test-id",
  "edc:properties": {
      "edc:id": "test-id",
      "edc:name": "asset-name-updated-321",
      "edc:description": "asset-description-updated",
      "edc:version": "0.0.2",
      "edc:contenttype": "application/json"
    },
  "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 should be @context and could very well be, what leads to the error while edc: is being resolved.

@NabilHouidi
Copy link
Author

Oops my bad 😅
@saschaisele-zf Thank you for the prompt reply.

@jimmarino
Copy link
Contributor

I'm reopening because I think the runtime should gracefully handle these situations. We should check Json-Ld reserved terms as part of validation and reject the request.

@ndr-brt
Copy link
Member

ndr-brt commented Jun 16, 2023

Yes, another issue is that our JsonLd service doesn't fail when it's not able to expand an input document but it returns a successful Result with an empty content.
Ref:

return Result.success(createObjectBuilder().build());

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.

4 participants