Item cannot be null error

@laurent, do you mind if I copy and paste some of your response over to the syncthing forum?

(from calmh, a syncthing maintainer)

When Syncthing writes to a file it first writes it out to a temporary file, all the while verifying the checksum of the data. It then moves that temp file in place over the old file. It doesn’t write in place, but what looks like it has happened here is that something has written a slightly smaller note on top of a larger one, leaving the old extra data in place at the end. I don’t know what would cause that but I have a hard time imagining Syncthing doing it.

Yes sure

This seems to not actually be related to syncthing.

I tested this on my old phone (a Pixel XL running Android 10). I uninstalled syncthing completely and changed the Joplin local sync folder to a new folder in the phone storage.

I can still cause the problem by doing the following:

  1. Create a new note with several lines.
  2. Hit Synchronize in Joplin. Returns just fine.
  3. Delete a line from the note.
  4. Hit Synchronize again.

For me, this will bring up the “Item cannot be null error”. @lerker100, is there any chance you can try something like this?

I had the same thing happen. When following your steps. I also have a pixel running Android 10

I just tested it on Linux and it works just fine. So it’s only on the app.

Any chance this is an Android 10 issue? Maybe it’s neither Joplin’s nor Syncthing’s fault. A few things stopped working when my Pixel was updated to Android 10. Just an idea…

Hmm, ok so it might be unrelated to syncthing then, but something to do with a recent version of Android. Please could you all confirm which version of Android you’re using?

I’m using Android 10 build QP1A.191005.007.A1

I am running Android 10 build QQ1A.191205.011.

Edit: I also can confirm the problem does not happen on an older phone running Android 8.

In the example I pasted above, I had deleted two characters in my note as a test. The result was an extra " 1" at the end of the .md file.

Just now I tried deleting 4 characters from another test note. The last line of the resulting .md file looks like this, "type_: 1_: 1", again showing the same number of extra characters on the end as I deleted from the note.

Interesting, so Android 10 adds characters to files. Not sure how we can fix this.

1 Like

It must be a combination of Android 10 and Syncthing though. e.g. I use Android 10 with sync to Nextcloud without problems.

Or it’s a bug between android 10 and the react-native-fs package.

This sounds like the same problem that Joplin is having with Android 10?

1 Like

I can throw my hat in the un-sync-able ring too. Notes created on my Pixel 1 (Android 10 build QP1A.191005.007.A1, Joplin version 1.0.312) sometimes have trouble syncing with desktop app (win10, Joplin 1.0.175; updated today, but problem existed previously too). I’m also using Syncthing, plus SyncTrayzor on desktop. The mashed-up metadata at the end of the .md files triggering the “cannot be null” error has been the same as other users have described.

Here’s the data from one file (some text that I revised quite a bit in Joplin, so plenty of lines were deleted/cut/pasted/etc.) that threw the “cannot be null” error recently:

id: 0ee89f0a28f048e994cd52d86d6efd3b
parent_id: a48143685047491fb15712e2be69215a
created_time: 2019-12-10T06:05:23.751Z
updated_time: 2019-12-10T19:09:20.454Z
is_conflict: 0
latitude: [there was an appropriate number here but I feel weird about sharing my exact location]
longitude: [same]
altitude: 146.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin
source_application: net.cozic.joplin-mobile
application_data: 
order: 0
user_created_time: 2019-12-10T06:05:23.751Z
user_updated_time: 2019-12-10T19:09:20.454Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
type_: 1ge: 1
type_: 1

I hadn’t made the connection that the error tends to happen in notes that have had lines removed, but I have seen it happen in notes consisting entirely of pasted text, even when all changes were made/saved while Syncthing was paused. I grabbed some text from Firefox on my phone, made a new note in Joplin, entered the title manually (is it working as intended if I can’t enter text in the body of the note without focusing the title field first, by the way?), and then pasted the text. I don’t think I deleted any lines in those notes after pasting the text.

All my notes on mobile open locally just fine, and the files appear where they should when syncing to desktop, but the desktop app won’t show the updates. It won’t even show the notebooks I’ve created on mobile. I edited the above file and deleted its .bak file, and that got it to appear in the desktop app. But it shows up in my Scratch notebook since the one it belongs in hasn’t synced properly.

I hope some of that helps!

Big disclaimer: I am not skilled in software development.

@archaicmeander, Your file does seem to show an extra 14 characters at the end of the file.

If my hunch is correct, Joplin wrote the contents of your new file on top of the old one and left everything after the first “type_: 1”, because the new file was 14 characters (including a carriage return) shorter than the old file.

type_: 1ge: 1
type_: 1

I just have encountered the same issue, using the Android app (version 1.0.312), running Android 10 on a OnePlus 7 Pro (OxygenOS 10.3.0.GM21AA).

I too first encountered it while using Syncthing, but I reproduced it again by fully wiping Joplin’s local data, re-opening it, and editing any of the default note by shortening it. This leaves the file of that note in the bad state described here.

There are a couple of workarounds described on the issue @rogerm4242 linked to (this one), from using a different library, to deleting the file before writing to it. It would be great if one of these could be implemented, since in the meantime, the Android app is quite unusable.

Seems to be fixed in the latest Android version.
Relevant github issue: https://github.com/laurent22/joplin/issues/2270

Any chance this is an Android 10 issue? Maybe it’s neither Joplin’s nor Syncthing’s fault. A few things stopped working when my Pixel was updated to Android 10. Just an idea…