pyld icon indicating copy to clipboard operation
pyld copied to clipboard

Treat invalid IRIs as errors in conversion to RDF

Open aucampia opened this issue 5 years ago • 3 comments

Currently invalid (i.e. non absolute) IRIs are ignored and tripples containing non absolute IRIs are omitted from the RDF resulting from to_rdf.

This patch changes this behaviour so that non absolute IRIs result in exceptions instead.

See https://github.com/digitalbazaar/pyld/issues/137

I am not sure what to do about testing, it seems there are no general unit tests, but rather just some scaffolding to run the w3c tests (which fail).

If you want I can add some general unit tests for you, just need to agree on the framework I guess.

aucampia avatar Sep 14 '20 19:09 aucampia

The spec specifically calls for such IRIs to be ignored, so raising an error would cause some tests to fail. I think the best thing to do is issue a warning, but a processor flag could cause an error to be raised.

gkellogg avatar Sep 14 '20 19:09 gkellogg

Thanks for the info @gkellogg

I think maybe to keep things clean it is best to add two options: strict and warn. If strict is set to True then raise when encountering an invalid IRI (i.e. not a valid absolute IRI), if warn is set to True then warn in the same case.

strict and warn could then be used for other similar cases in future.

Not sure what you think is best, feedback is appreciated.

aucampia avatar Sep 14 '20 19:09 aucampia

The other option is maybe to just have warn and errorOnInvalidIRI - but I worry that this will lead to proliferation of errorOn... options.

aucampia avatar Sep 14 '20 19:09 aucampia