Skip to content

codemeta: Workaround pyld issue for compact operation

pyld is not correctly loading json-ld content from http*://schema.org (see https://github.com/digitalbazaar/pyld/issues/154) and raises an exception when attempting to compact a codemeta document having schema.org in its @context list.

As a workaround, remove schema.org from the @context list of a codemeta document before compacting it.

Fix citation generation for https://archive.softwareheritage.org/browse/content/sha1_git:b338526dc5431c294b0ace63a0d0cafb1da1b34c/?origin_url=https://github.com/mpadge/packgraph&path=codemeta.json

('Could not expand input before compaction.',)
Type: jsonld.CompactError
Cause: ('Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.',)
Type: jsonld.InvalidUrl
Code: loading remote context failed
Details: {'url': 'http://schema.org', 'cause': Exception('http://schema.org')}  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/jsonld.py", line 717, in compact
    expanded = self.expand(input_, options)
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/jsonld.py", line 870, in expand
    expanded = self._expand(active_ctx, None, document, options,
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/jsonld.py", line 2302, in _expand
    active_ctx = self._process_context(
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/jsonld.py", line 3049, in _process_context
    resolved = options['contextResolver'].resolve(active_ctx, local_ctx, options.get('base', ''))
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/context_resolver.py", line 58, in resolve
    resolved = self._resolve_remote_context(
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/context_resolver.py", line 108, in _resolve_remote_context
    context, remote_doc = self._fetch_context(active_ctx, url, cycles)
  File "/opt/swh/.local/lib/python3.10/site-packages/pyld/context_resolver.py", line 148, in _fetch_context
    raise jsonld.JsonLdError(
Edited by Antoine Lambert

Merge request reports