I have been working on tracker project for the past 10 weeks to improve its support for custom ontologies. It has been a great journey and I gained great software engineering experience by exploring the project and its architecture. Also, the project mentors helped me a lot during the project. In this article I’m going to summarize the work done in the project and the future work.
Work Done
Fix crashes caused by comments in the ontology file
Tracker was only supporting comments inside the ontology file if they appeared at the beginning of triple statements while any comments at the middle of any statement would lead tracker to crash. This problem is fixed in the MR !443 (Merged). It makes tracker support comments anywhere in the ontology file outside an IRIREF or String (the same as stated in RDF Turtle Specifications). Also, added test cases to test this feature.
Track the current line being parsed in the ontology file
In the following MR !447 (MERGED), I added the feature of tracking the current line and column being parsed in the ontology file. This feature will be used later to tell user the specific location of the statement that caused the ontology parsing error.
Fix crash caused by unknown prefixes in the ontology file
In the same MR !447 (MERGED), I fixed the crash that happen when any statement in the ontology uses a prefix which is not defined before (may happen if user misspelled the prefix). Currently, if the ontology contains an unknown prefix, it will propagate a descriptive error message to the process that established the connection with tracker instead of crashing. Also, the MR request contains test cases to test both the feature of tracking the current line and column numbers and the propagation of errors that may happen while parsing the ontology.
Properly rollback the database when an error is occurred while building or updating it
Tracker was saving a half-completed database if an error occurred while building a new one. It made tracker crash the next time it starts even if the user fixed the problem that caused the error in the first place, as tracker tries to read from the non-consistent database. Also, if an error occurred while the database is being updated to integrate with the changes in the ontology, some changes may not completely be rolled back which also leaves the database in an inconsistent state. Also, there were some errors that are ignored while updating the db which also lead to the same problem.
These problems are fixed in the MR !457 (MERGED) and some test cases are added to ensure that the changes in the database are completely rolled back either if the error occurred while building or updating it.
Properly handle errors that may happen while parsing the ontology
The ontology parser wasn’t properly handle many parsing errors that may appear in the ontology file. The parser was ignoring these errors; it only shows warnings to user, but it continues parsing the ontology and builds the database that is described by the malformed ontology file.
These errors are properly handled in the MR !452 (OPEN), it shows warnings to user about all the parsing errors in the ontology file and propagate a descriptive error message to the process that established the connection with tracker. Also, a test case is added to test the error propagation.
Prefix errors and warnings with line and column numbers that caused the error
In the same MR !452 (OPEN), all errors and warnings that are printed while parsing the ontology file are prefixed by the position of the statement that caused the error. Which makes very easy to user to find out the problems in the ontology file (As we can see in the following video).
Future Work
Adding support for out of order definitions in the ontology file
Currently, tracker doesn’t support out of order definition which means using an object before defining it. This will be done by defining priorities for each type of statements in the ontology file. So, the definition statements (which define a new object) are parsed first then the statements that has lower priority then the more lower priority statements until parsing the statements in all priority levels.
Final Words
It was a great experience working with GNOME community. I learned a lot about exploring, debugging and understanding the structure of already built project. I learned a lot of best practices in software engineering and in C language in specific. I would like to thank my mentors Carlos and Sam who helped me a lot before and after I get accepted in the project. Also, I enjoyed giving a talk in GUADEC conference. Looking forward to continue contributing to GNOME projects.