Sparqlbuilder should reuse IRI validation code #3182
Replies: 14 comments
-
@jeenbroekstra I'm considering to implement this and currently am looking for the IRI validation code in RDF4J. Any pointers? |
Beta Was this translation helpful? Give feedback.
-
Is it |
Beta Was this translation helpful? Give feedback.
-
Or just call |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
I would like to work on this issue. Please suggest what needs to be done regarding this. |
Beta Was this translation helpful? Give feedback.
-
Hi @anmolsinghal98 that'd be great! Please have a look at the contributor guidelines first, in particular the points on how to sign the Eclipse Contributor Agreement. Let me know if you need any help with any of it. As for where to start with this issue: have a look at the sparqlbuilder code, particularly the part that parses/validates IRIs. A good way to approach might be to write some tests that use various legal and illegal iri strings and then fix test failures as you go. Like said above: the ParsedIRI class contains very complete validation code, so it would be ideal if you could reuse that. Feel free to set up an early draft and, even if it doesn't work yet, submit as draft PR so we can discuss. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your guidance. Will proceed accordingly and let you know in case of difficulties. |
Beta Was this translation helpful? Give feedback.
-
@anmolsinghal98 , @29kritika and I have signed the Eclipse Contributor Agreement. Now as per contributor guidelines, we'd like to inform that we would be working on the issue. |
Beta Was this translation helpful? Give feedback.
-
@jeenbroekstra I have made a pull request adding some tests for ParsedIRI class. The same is being used in the Sparqlbuilder Rdf class to create and instantiate IRIs. Please let me know how to proceed with the issue. I am yet to determine where exactly the IRI instantiation is failing. |
Beta Was this translation helpful? Give feedback.
-
...that is surprising - I had it in my head that the SparqlBuilder didn't use the ParsedIRI at all. Let me take a closer look, but it might be that this issue has in fact already been fixed. |
Beta Was this translation helpful? Give feedback.
-
Hm. From what I can tell we indeed already use However, what the SparqlBuilder currently does is just assume that something is a prefixed name rather than a full IRI if validation fails, so it returns the original input string as the value. I'm afraid this isn't a simple bug that can be easily fixed. The builder should verify that, if something doesn't parse as a legal IRI, it is at least a legal prefixed name (meaning that the prefix is known and together they form a valid IRI). But the way the builder is designed doesn't easily make that possible. |
Beta Was this translation helpful? Give feedback.
-
We'll need to do some design and set some expectations around what we want SparqlBuilder to do. Currently, it is a very light-weight DSL that just produces a query string without doing much of anything in terms of validating that the result is legal SPARQL. I would suggest to park this issue for now, and perhaps open a separate discussion around how we could best approach that. |
Beta Was this translation helpful? Give feedback.
-
Alright. Thanks for the clarification. |
Beta Was this translation helpful? Give feedback.
-
IMHO the builder should not be too sophisticated in terms of verification. I have been able to work around many shortcomings simply because the current builder architecture is lightweight and forgiving. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
See comment on GH-1038, currently it is assumed (hard-coded) that IRIs start with either mailto:, http: or https:
So the code will break on other valid schemes like urn: etc.
Recommended approach is to reuse the existing IRI validation code
Beta Was this translation helpful? Give feedback.
All reactions