Fix recursion error when parsing nested SERVICE calls#3408
Open
vemonet wants to merge 1 commit intoRDFLib:mainfrom
Open
Fix recursion error when parsing nested SERVICE calls#3408vemonet wants to merge 1 commit intoRDFLib:mainfrom
SERVICE calls#3408vemonet wants to merge 1 commit intoRDFLib:mainfrom
Conversation
* update the `Comp(TokenConverter)` class to properly track and parse SERVICE calls instead of re-parsing the entire input which caused RecursionError with nested SERVICE * add a test for parsing nested SERVICE call in `test_sparql_parser.py` * in existing `test_translate_algebra.py` update the xfail for `test_other__service1.txt` as it now fails due an issue with parsing nested OPTIONAL/SERVICE blocks instead of triggering a RecursionError (it is a different issue that already existed) * added `.poetry` to black skip as this was causing error when running black with precommit hook fixes RDFLib#2136
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
This PR fixes #2136 where RDFLib faces infinite recursion loop when a
SERVICEcall is used in anotherSERVICEcall, which is not uncommon (Wikidata, one of the most popular public triplestore usesSERVICEcall to resolve label, so if someone tries to do a service call to wikidata with labels they would face error at parsing time when executing it with rdflib), e.g.Comp(TokenConverter)class to properly track and parseSERVICEcalls instead of re-parsing the entire input which causedRecursionErrorwith nested servicestest_sparql_parser.pytest_translate_algebra.pyupdate the xfail fortest_other__service1.txtas it now fails due an issue with parsing nested OPTIONAL/SERVICE blocks instead of triggering a RecursionError (it is a different issue that already existed but was never noticed as the recursion error was triggered first).poetryto black skip as this was causing error when running black with precommit hook, preventing to commitNote fixing nested OPTIONAL/SERVICE blocks would require small changes to
plugins/sparql/algebra.pyto properly handleOptionalGraphPatternnodes in_AlgebraTranslatorclass. I can add it to this PR if you want, or create a new PR later@nicholascar @aucampia
Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.