IIIF/presentation-validator

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:

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.

There's a commit for this hack here.

Thanks John. Just looking further into this and I think its related to this method:

https://github.com/iiif-prezi/iiif-prezi/blob/da5da0cca1d208b60362e9314f022fd39d4c8a28/iiif_prezi/loader.py#L31

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:

iiif-prezi/iiif-prezi#58

So temporary fix is OK until this is merged and a new version is released.

Fixed with: #101