-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: avoid uri shadowing #280
Conversation
Following invalid URIs or CURIEs which weren't catched by the previous validation are not allowed anymore:
Following invalid URIs which weren't catched by the previous validation are not allowed anymore:
Furthermore following valid URIs that were being rejected are allowed:
Footnotes
|
Assuming the support for empty URIs (same-document reference) makes any difficulties, I don't think that deviating from the standard would harm much there. |
@cthoyt the module providing validation functions here goes in the direction of what I was wishing to see in the It doesn't resolve the URI - CURIE ambiguity where both are accepted yet though. |
Small hint for easy manual testing:
will return a regex match object, since it succeeds. |
Improve URI and CURIE validation using regular expressions based on the corresponding official specifications. URI and CURIE validation mechanisms where reporting valid URIs (like a URN 'urn:abc:123') as invalid. This patch fixes this issue. Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
'meaning' is declared to be Uriorcurie according [1], but at least one example being used for testing wasn't compliant (neither '[' nor ']' are allowed in the reference part of a curie) and therefore the introduced stricter URI and CURIE validation was failing. This patch fixes the issue. [1]: https://linkml.io/linkml-model/latest/docs/meaning/ Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
'source_nodes' is declared to be Uriorcurie according [1], but at least one example being used for testing wasn't compliant (' ! unit' is not allowed in the reference part of a curie) and therefore the introduced stricter URI and CURIE validation was failing. This patch fixes the issue. [1]: https://linkml.io/linkml-model/latest/docs/source_nodes/ Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
Empty URIs are so-called same-document references and are legal URIs, therefore fixing the wrong text expectation (derived from the previous non-standard conform implementation). Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
Rename test for URIorCURIE types and also focus only on testing that class, moving tests applying to the URI class to the corresponding test. Also add/modify following tests: * 'abc:[123]' is an invalid CURIE. * ':123' is an invalid URI (but a valid CURIE) * '' is a valid URI (a same-document reference) * 'rdf:type' is a valid URI (also a valid CURIE) * 'urn:abc:123' is a valid URI (since it's a valid URN) Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
Adding all URIs shown in the URI Wikipedia page [1] to the tests. [1]: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
I've added named groups for better unterstanding of how the validator is parsing the passed strings.
returns
|
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #280 +/- ##
==========================================
+ Coverage 61.81% 62.11% +0.29%
==========================================
Files 62 63 +1
Lines 8393 8459 +66
Branches 2164 2169 +5
==========================================
+ Hits 5188 5254 +66
Misses 2599 2599
Partials 606 606
☔ View full report in Codecov by Sentry. |
Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
Add new tests to improve test coverage. Remove also unused (and therefore not tested) functionality. Signed-off-by: Silvano Cirujano Cuesta <[email protected]>
@sierra-moxon are you taking care of assigning the PR or are you expecting me to pick someone? |
Thanks @Silvanoc! I reviewed and merged; this is terrific! please feel free to assign one of us as a reviewer if needed. :). I also upped your permissions on the repo so you should be able to branch instead of fork if that is easier. |
I'm not sure I know exactly who do you mean by "us". I probably have a rough idea, but I cannot find any place stating something like "this is the LinkML" team or "these are the maintainers". |
@Silvanoc I'm glad you found a place for this! |
URIorCURIE validation function is wrongly identifying as CURIEs certain URIs. This patch first tries to validate if a URIorCURIE is a valid URI, otherwise it tries to validate if it's a valid CURIE.
Fixes linkml/linkml#1662