HamburgChimps / apple-notes-liberator

Free your Apple Notes data from Notes.app
MIT License
968 stars 20 forks source link

notesCloudObject is null #25

Closed lhagan closed 1 year ago

lhagan commented 1 year ago

I'm getting the following error when I run the jar:

Cannot invoke "de.hamburgchimps.apple.notes.liberator.entity.NotesCloudObject.getzTypeUti()" because "notesCloudObject" is null

apple-notes-liberator appears to have found the correct database since it copied notes.sqlite into the liberated-notes folder. I manually queried that database using the following command:

sqlite3 notes.sqlite "SELECT writefile('note_data.gz', zdata) FROM zicnotedata WHERE znote = 100"

The extracted data includes the text of one of my notes, so I don't think the problem is with the source data.

My configuration:

Here's some additional information from the log:

ERROR [de.ham.app.not.lib.dat.Table] (main) Failed to parse table: java.lang.RuntimeException: no data to parse

Any ideas of what might be tripping it up?

alexkolson commented 1 year ago

Hi @lhagan, sorry you are facing this issue! I have just released a potential fix! Could you try v1.0.4 and let me know if it works for you?

In case you are interested in more detailed information: The (potential) fix checks to make sure the particular notes object that the application is attempting to parse is not null before attempting to determine what type it is. My suspicion is that the particular notes object that the application is attempting to parse is deleted but still lingering around as an attachment in the note data itself. My general impression is that deleted note objects and references to deleted note objects can still linger around in the Notes.app database for quite some time, and apple-notes-liberator doesn't handle such cases as well as it should. Hopefully with this change though, it should no longer attempt to determine the type of a deleted notes object and thus not throw a NullPointerException.

Of course I could be wrong and the problem could be something else entirely! I am curious to see if v1.0.4 works for you.

Long-term, I would like to be able to have better tests for deleted notes cases, but right now my test case is "manually run against my Notes.app database that contains deleted notes and see if it works", which I know is not great. Perhaps I can seed some test sqlite databases with data representing different scenarios and use them to write some automated tests. But anyway, I digress. :)

Thank you for taking the time to make an issue and I hope to hear back from you!

lhagan commented 1 year ago

Wow -- thanks for the quick solution! v1.0.4 fixed this issue.

alexkolson commented 1 year ago

Awesome! Glad to hear it!