w3c-ccg / traceability-interop

Verifiable Credentials for Supply Chain Interoperability Specification for HTTP

Home Page:https://w3id.org/traceability/interoperability

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] expanding traceability did document with pyld

PatStLouis opened this issue · comments

I'm using the pyld library in my solution. Given the following json-ld document:

{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/traceability/v1"
  ],
  "service": [
    {
      "id": "did:web:example.com#traceability-api",
      "type": ["TraceabilityAPI"],
      "serviceEndpoint": "https://example.com"
    }
  ]
}

when I try to expand it

jsonld.expand(document)

I get the following error:

pyld.jsonld.JsonLdError: ('Tried to nullify a context with protected terms outside of a term definition.',)
Type: jsonld.SyntaxError
Code: invalid context nullification

Removing one of the contexts bypasses this error, however, both should be present according to the spec. Commenting out the service.type also bypasses this error.

Could someone with more knowledge around json-ld shed some light on this issue?

I noticed the TraceabilityAPI term has an empty context:
"TraceabilityAPI":{"@id":"https://w3id.org/traceability#TraceabilityAPI","@context":{}}

This is appears to be a bug on our end,

this looks like a traceability vocabulary issue where TraceabilityAPI term does not have a context defined.

I'm not very good with JSON-LD, but do we really even need to define a TraceabilityAPI term in our vocab since service is defined in https://www.w3.org/ns/did/v1? I would like to see this reassigned to someone more familiar with JSON-LD.

We have PR #923 open for this, we should discuss there if you have any issues with it

PR opened on the pyld library, I think I found the issue. Some peer review would be appreciated!

Closing as a new pyld version has been released and no longer fails expanding empty contexts