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

Policy Definition API accepts policy that causes exception when calling catalog and refuses other policy #3687

Closed
sfranke43 opened this issue Dec 5, 2023 · 10 comments
Labels
stale Open for x days with no activity triage all new issues awaiting classification

Comments

@sfranke43
Copy link

When calling the policy definition API with:
curl -d '{ "@context": { "edc": "https://w3id.org/edc/v0.0.1/ns/", "odrl": "http://www.w3.org/ns/odrl/2/" }, "@id": "test_data_medical(1).json_policy", "policy": { "@type": "set", "@context": "http://www.w3.org/ns/odrl.jsonld", "permission": [{"target":"test_data_medical(1).json", "action": "transform","constraints": [{ "leftOperand": "product", "operator": "eq", "rightOperand": "allergy", "comment": "keep_data"},{ "leftOperand": "product", "operator": "eq", "rightOperand": " symptoms", "comment": "keep_data"},{ "leftOperand": "product", "operator": "eq", "rightOperand": " previous sickness", "comment": "keep_data"}]}], "prohibition":[{"target":"test_data_medical(1).json", "action": "transform","constraint": [{ "leftOperand": "dateTime", "operator": "eq", "rightOperand": "2024-05-12", "comment": "save_until"}]}], "obligation":[{"target":"test_data_medical(1).json", "action": "transform","constraint": [{ "leftOperand": "resolution", "operator": "eq", "rightOperand": "allergy:2", "comment": "abstractLvl"},{ "leftOperand": "resolution", "operator": "eq", "rightOperand": " symptoms:1", "comment": "abstractLvl"},{ "leftOperand": "resolution", "operator": "eq", "rightOperand": " previous sickness:3", "comment": "abstractLvl"}]},{"target":"test_data_medical(1).json", "action": "transform","constraint": [{ "leftOperand": "product", "operator": "eq", "rightOperand": "allergy", "comment": "differantialPrivacy"},{ "leftOperand": "product", "operator": "eq", "rightOperand": " symptoms", "comment": "differantialPrivacy"}]}] } }' -H 'content-type: application/json' http://localhost:19193/management/v2/assets \ -s | jq

Expected behavior: accepting the policy

Real behavior:
`

<title>Error 400 Bad Request</title>

HTTP ERROR 400 Bad Request

URI:/management/v2/policydefinitions
STATUS:400
MESSAGE:Bad Request
SERVLET:EDC-management

Powered by Jetty:// 11.0.16
`

Without adding the "context" in the policy and using my own made up strings as constarints, the policy is accepted. However when trying to call the catalog, it return that "action" is Null and crashes.

Copy link

github-actions bot commented Dec 5, 2023

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

@ndr-brt
Copy link
Member

ndr-brt commented Dec 5, 2023

You are not specifying the @context correctly, the @vocab attribute is needed because there are not-namespaced properties (e.g. policy) and json-ld needs to know what's the default IRL to use.
Please try with:

{
  "@context": {
    "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
  },
  "@id": "test_data_medical(1).json_policy",
  "policy": {
    "@type": "set",
    "@context": "http://www.w3.org/ns/odrl.jsonld",
    "permission": [
      {
        "target": "test_data_medical(1).json",
        "action": "transform",
        "constraints": [
          {
            "leftOperand": "product",
            "operator": "eq",
            "rightOperand": "allergy",
            "comment": "keep_data"
          },
          {
            "leftOperand": "product",
            "operator": "eq",
            "rightOperand": " symptoms",
            "comment": "keep_data"
          },
          {
            "leftOperand": "product",
            "operator": "eq",
            "rightOperand": " previous sickness",
            "comment": "keep_data"
          }
        ]
      }
    ],
    "prohibition": [
      {
        "target": "test_data_medical(1).json",
        "action": "transform",
        "constraint": [
          {
            "leftOperand": "dateTime",
            "operator": "eq",
            "rightOperand": "2024-05-12",
            "comment": "save_until"
          }
        ]
      }
    ],
    "obligation": [
      {
        "target": "test_data_medical(1).json",
        "action": "transform",
        "constraint": [
          {
            "leftOperand": "resolution",
            "operator": "eq",
            "rightOperand": "allergy:2",
            "comment": "abstractLvl"
          },
          {
            "leftOperand": "resolution",
            "operator": "eq",
            "rightOperand": " symptoms:1",
            "comment": "abstractLvl"
          },
          {
            "leftOperand": "resolution",
            "operator": "eq",
            "rightOperand": " previous sickness:3",
            "comment": "abstractLvl"
          }
        ]
      },
      {
        "target": "test_data_medical(1).json",
        "action": "transform",
        "constraint": [
          {
            "leftOperand": "product",
            "operator": "eq",
            "rightOperand": "allergy",
            "comment": "differantialPrivacy"
          },
          {
            "leftOperand": "product",
            "operator": "eq",
            "rightOperand": " symptoms",
            "comment": "differantialPrivacy"
          }
        ]
      }
    ]
  }
}

note: when you get error like these is because the json-ld library is not able to expand the body, eventually you can try it out on the json-ld playground manually

@ndr-brt ndr-brt added the triage all new issues awaiting classification label Dec 5, 2023
@sfranke43
Copy link
Author

I get the same response for that.

<title>Error 400 Bad Request</title>

HTTP ERROR 400 Bad Request

URI:/management/v2/policydefinitions
STATUS:400
MESSAGE:Bad Request
SERVLET:EDC-management

Powered by Jetty:// 11.0.16

@ndr-brt
Copy link
Member

ndr-brt commented Dec 5, 2023

could you please add some details, as edc version? any stack traces? OS?

@sfranke43
Copy link
Author

I am on EDC release 0.3.1, Windows 10. I have slightly edited the http dataplane and my goal is to pass the variables of the contract onto my dataplane. the stack trace is:

WARNING 2023-12-05T16:50:10.8198325 Error expanding JSON-LD structure
JsonLdError[code=There was a problem encountered loading a remote context [code=LOADING_REMOTE_CONTEXT_FAILED]., message=There was a problem encountered loading a remote context [code=LOADING_REMOTE_CONTEXT_FAILED].]
        at com.apicatalog.jsonld.context.ActiveContextBuilder.fetch(ActiveContextBuilder.java:539)
        at com.apicatalog.jsonld.context.ActiveContextBuilder.create(ActiveContextBuilder.java:174)
        at com.apicatalog.jsonld.expansion.ObjectExpansion.initLocalContext(ObjectExpansion.java:200)
        at com.apicatalog.jsonld.expansion.ObjectExpansion.expand(ObjectExpansion.java:102)
        at com.apicatalog.jsonld.expansion.Expansion.compute(Expansion.java:119)
        at com.apicatalog.jsonld.expansion.ObjectExpansion1314.expand(ObjectExpansion1314.java:946)
        at com.apicatalog.jsonld.expansion.ObjectExpansion.expand(ObjectExpansion.java:121)
        at com.apicatalog.jsonld.expansion.Expansion.compute(Expansion.java:119)
        at com.apicatalog.jsonld.processor.ExpansionProcessor.expand(ExpansionProcessor.java:124)
        at com.apicatalog.jsonld.api.ExpansionApi.get(ExpansionApi.java:131)
        at org.eclipse.edc.jsonld.TitaniumJsonLd.expand(TitaniumJsonLd.java:67)
        at org.eclipse.edc.web.jersey.jsonld.JerseyJsonLdInterceptor.aroundReadFrom(JerseyJsonLdInterceptor.java:52)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
        at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundReadFrom(MappableExceptionWrapperInterceptor.java:49)
        at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
        at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1072)
        at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:919)
        at org.glassfish.jersey.server.ContainerRequest.readEntity(ContainerRequest.java:290)
        at org.glassfish.jersey.server.internal.inject.EntityParamValueParamProvider$EntityValueSupplier.apply(EntityParamValueParamProvider.java:73)
        at org.glassfish.jersey.server.internal.inject.EntityParamValueParamProvider$EntityValueSupplier.apply(EntityParamValueParamProvider.java:56)
        at org.glassfish.jersey.server.spi.internal.ParamValueFactoryWithSource.apply(ParamValueFactoryWithSource.java:50)
        at org.glassfish.jersey.server.spi.internal.ParameterValueHelper.getParameterValues(ParameterValueHelper.java:68)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$AbstractMethodParamInvoker.getParamValues(JavaResourceMethodDispatcherProvider.java:109)
        at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
        at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:93)
        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$RequestDispatchable.dispatch(HttpChannel.java:1598)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
        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.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)
Caused by: JsonLdError[code=The document could not be loaded or parsed [code=LOADING_DOCUMENT_FAILED]., message=URL scheme [http] is not supported.]
        at com.apicatalog.jsonld.loader.SchemeRouter.loadDocument(SchemeRouter.java:59)
        at org.eclipse.edc.jsonld.TitaniumJsonLd$CachedDocumentLoader.loadDocument(TitaniumJsonLd.java:146)
        at com.apicatalog.jsonld.context.ActiveContextBuilder.fetch(ActiveContextBuilder.java:535)
        ... 64 more

@ndr-brt
Copy link
Member

ndr-brt commented Dec 5, 2023

EDC is not fully supported to run on windows machine, please run it into a containered environment on linux.
another advice is to update to the latest version (0.4.1)

@ndr-brt
Copy link
Member

ndr-brt commented Dec 13, 2023

It should have been solved by #3670, could you try it again with the latest main commit?

Copy link

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

@github-actions github-actions bot added the stale Open for x days with no activity label Dec 28, 2023
Copy link

github-actions bot commented Jan 4, 2024

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

1 similar comment
Copy link

github-actions bot commented Jan 4, 2024

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 Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Open for x days with no activity triage all new issues awaiting classification
Projects
None yet
Development

No branches or pull requests

2 participants