Problem synchronizing tags created via the API (bug?)

I have a strange situation with synchronizing tags in a multi-install context.
This is a bit long but I wanted to clearly pinpoint what I think may be a bug in synchronization.

My setup is

  • a Windows desktop Joplin (Joplin 1.0.201 (prod, win32))
  • a CLI in a docker container (joplin 1.0.163 (prod) → interestingly enough, I installed that today via npm so I am not sure why the versions differ)
  • a NextCloud installation to which both instances synchronize

To simplify things, I copied database.sqlite from my desktop installation to the docker (CLI).

The ultimate goal of this is to use the API in the docker to automatically modify tags in notes based on #hashtags (something I will open source someday as it may be useful to others)

What works:

  • creating a note and add tags on the desktop + synchronization to NextCloud
  • creating a note and add tags via the CLI + synchronization to NextCloud
  • in both environments I see the notes created by the other instance

What does not work:

I added, in the container, via some code (= calling the API) tags to notes. To take a specific example, I added the tag dockerhashtag to note notefromdocker. Here is how it is seen on the commandline:

root@00f5832d94a3:/# joplin tag list dockerhashtag
        notefromdocker
root@00f5832d94a3:/# joplin tag notetags notefromdocker
dockerhashtag

So it looks good. After joplin sync I expected to see that tag on the desktop (after also synchronizing it). The tag does not show up.

To be absolutely sure, I added some text from the CLI (joplin edit notefromdocker), synchronized and behold, the text is visible on the desktop (again, after synchronizing it as well).

So why doesn't the tag synchronize?

Then I did another test: to add, via the CLI, a tag (tagfromcli) to that note. I now have:

root@00f5832d94a3:/# joplin tag notetags notefromdocker
dockerhashtag
tagfromcli

So both are visible and after a sync ... only tagfromcli is visible on the desktop!

I am at loss here.

Last test: to add a tag (tagfromdesktop) to that note from the desktop. Synchronization and then

root@00f5832d94a3:/# joplin sync
Synchronisation target: Nextcloud (5)
Starting synchronisation...
Fetched items: 1/17.
Downloading resources...
Created local items: 2. Fetched items: 17/17. Completed: 2020-05-10 12:13
root@00f5832d94a3:/# joplin tag notetags notefromdocker
dockerhashtag
tagfromdesktop
tagfromcli

Only the tags added either by the CLI or the desktop app are synchronized. The one via the API is not.

Help! :slight_smile:

Tags are represented as .md files containing type_: 5 in your sync target. You can find one such file for a tag created via the API and one create by the CLI and compare them, especially their update_time.

I went to Nextcloud and from there I see:

# grep tagfrom *
514420c10a3c4a95b54945bff3683a82.md:tagfromdesktop
5db11d42689f49ac9a443a45fd4f6f10.md:tagfromcli

# cat 514420c10a3c4a95b54945bff3683a82.md 
tagfromdesktop

id: 514420c10a3c4a95b54945bff3683a82
created_time: 2020-05-10T12:12:53.117Z
updated_time: 2020-05-10T12:12:53.117Z
user_created_time: 2020-05-10T12:12:53.117Z
user_updated_time: 2020-05-10T12:12:53.117Z
encryption_cipher_text:
encryption_applied: 0
is_shared: 0
type_: 5

# cat 5db11d42689f49ac9a443a45fd4f6f10.md
tagfromcli

id: 5db11d42689f49ac9a443a45fd4f6f10
created_time: 2020-05-10T11:59:16.970Z
updated_time: 2020-05-10T11:59:16.970Z
user_created_time: 2020-05-10T11:59:16.970Z
user_updated_time: 2020-05-10T11:59:16.970Z
encryption_cipher_text:
encryption_applied: 0
is_shared: 0
type_: 5

# grep dockerhashtag *
234d7aaf-cdf3-4138-9213-73f750e25b7b.md:dockerhashtag

# cat 234d7aaf-cdf3-4138-9213-73f750e25b7b.md
dockerhashtag

id: 234d7aaf-cdf3-4138-9213-73f750e25b7b
created_time: 2020-05-10T11:38:04.823Z
updated_time: 2020-05-10T11:38:04.823Z
user_created_time: 2020-05-10T11:38:04.823Z
user_updated_time: 2020-05-10T11:38:04.823Z
encryption_cipher_text:
encryption_applied: 0
is_shared: 0
type_: 5

The times seem consistent, especially the last one which should be picked up by the desktop

So which one is not synchronized? Is it dockerhashtag?
One obvious difference is the id format, though I’m not sure whether that’s important or not.

Yes, this is dockerhashtag (I hope the different steps in my question are clear - I used the same tag names across).

Ahhhh - you are probably right about the id. For notes, the documentation says

When a new note is created, it is automatically assigned a new unique ID so normally you do not need to set the ID . However, if for some reason you want to set it, you can supply it as the id property. It needs to be a 32 characters long hexadecimal string. Make sure it is unique , for example by generating it using whatever GUID function is available in your programming language.

Mine is UUID4. I will check this out.

That was it - thanks a lot for the hint!