stellio-hub / stellio-context-broker

Stellio is an NGSI-LD compatible context broker
https://stellio.readthedocs.io
Apache License 2.0
25 stars 11 forks source link

503 error using a specific user context #1162

Closed EliottPaillard closed 1 month ago

EliottPaillard commented 1 month ago

Hello,

Using any of the last Stellio version, when creating an entity with as @context :

[ "https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite.jsonld", "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" ]

Stellio returns a 503 error and I don't know why.

Please may you help me?

bobeal commented 1 month ago

Hi @EliottPaillard,

Indeed, as per the JSON-LD specification, a remote JSON-LD context must be served with an appropriate content type (see point 6 in https://www.w3.org/TR/json-ld11-api/#loaddocumentcallback: Otherwise, the retrieved document's [Content-Type](https://tools.ietf.org/html/rfc2045#section-5) is neither application/json, application/ld+json, nor any other media type using a +json suffix as defined in [[RFC6839](https://www.w3.org/TR/json-ld11-api/#bib-rfc6839)]. Reject the promise passing a [loading document failed](https://www.w3.org/TR/json-ld11-api/#dom-jsonlderrorcode-loading-document-failed) error.).

As the JSON-LD processor used by Stellio is quite strict with the specification, https://forge.etsi.org/rep/cim/ngsi-ld-test-suite/-/raw/develop/resources/jsonld-contexts/ngsi-ld-test-suite.jsonld is rejected because it is served as text/plain. Other context brokers are more lenient on this...

This is why we are using a JSON-LD context served on GitHub Pages when running the test suite with Stellio (see https://github.com/stellio-hub/ngsi-ld-test-suite/commit/7fe19ac9f01bcb64e65b5cde624aba4a0a68b771 for instance).

PS: avoid using https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld as it is a very old context (before version 1.3 of the specification) and many NGSI-LD features will not work with it. For the current state of test suite, you can for instance use https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld.