Validating Manifests throws a Validation Error
regisrob opened this issue · 5 comments
The validator throws this error on 2.1 Manifests, even though they do seem to validate (and be valid):
Validation Error: ('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://iiif.io/api/presentation/2/context.json', 'cause': TypeError('load_document_local() takes 1 positional argument but 2 were given',)}
Examples:
- https://gallica.bnf.fr/iiif/ark:/12148/btv1b10038246f/manifest.json
- https://iiif.durham.ac.uk/manifests/trifle/32150/t1/mr/20/t1mr207tp393/manifest
- https://iiif.bodleian.ox.ac.uk/iiif/manifest/233c07e4-5858-4ebd-b17d-cbfdcff76879.json
Moreover, I noticed another issue while validating this 3.0 Manifest: https://preview.iiif.io/cookbook/0009-book-1/recipe/0009-book-1/manifest.json
Validation Error: Top level @context is not known
even though the @context
seems ok.
There is also a warning indicating a potential CORS issue on fixtures.iiif.io manifests:
Warnings:URL does not have correct access-control-allow-origin header: got "", expected *`
Regarding 2.0/2.1 Manifests, I got a local copy of this to work by hacking iiif_prezi. I changed this line to:
jsonld.set_document_loader(jsonld.requests_document_loader(timeout=60))
And I did a 'pip install requests'. iiif_prezi uses jsonld from pyld- this hack switches jsonld from a custom document loader that loads context documents locally to one that just requests them over http.
I'm still not sure why this would have suddenly stopped working a few weeks ago, but hopefully this saves other people some debugging time.
Thanks John. Just looking further into this and I think its related to this method:
which overrides the default set document loader but has an old method signature:
def load_document_local(url):
where it is now:
def load_document_local(url, options):
The method looks to have changed with the release of JSON-LD 1.1. As quick fix I think I will take your change but it would be good to get iiif_prezi
fixed so that it can use a local context.
It looks like there is already a pull request to fix this in iiif_prezi
:
So temporary fix is OK until this is merged and a new version is released.
Fixed with: #101