dengste / org-caldav

Caldav sync for Emacs orgmode
GNU General Public License v3.0
712 stars 105 forks source link

Recurring sync error: Could not find UID xxxxx.xxxx on Nextcloud #273

Closed tenpast closed 1 year ago

tenpast commented 1 year ago

Yesterday I posted on Issue #230 thinking I had resolved the problem, but this turns out not to be the case.

The workaround explained on that post worked to achieve a first sync (adding the file to org-id-files by creating an ID manually and then deleting it). However, on subsequent syncs I end up getting a Could not find UID 20230501T092828.997173 error. I'm including the ID number in case this makes a difference, as I have set it to ISO time format.

Once this error happens, the only way to re-sync is to delete the calendars on Nextcloud, restore from a backup made prior to syncing with org-caldav, using org-caldav-delete-everything and starting again.

Relevant software:

Archlinux Emacs 28.2 Org Mode 9.5.5 org-caldav 20230421.1620

Current configuration:


  (use-package org-caldav
    :config
    (setq org-caldav-url "https://nextcloud.url/user")
    (setq org-caldav-calendars
      '((:calendar-id "calendar-1" :files ("~/calendar-1.org")
         :inbox "~/calendar-1.org")
        (:calendar-id "calendar-2" :files ("~/calendar-2.org")
         :inbox "~/calendar-2.org")
        (:calendar-id "calendar-3" :files ("~/calendar-3.org")
         :inbox "~/calendar-3.org")))
    (setq org-icalendar-timezone "My/Timezone")
    (setq org-icalendar-alarm-time 30)
    (setq org-caldav-delete-org-entries "always")
    (setq org-caldav-delete-calendar-entries "always")
    (run-with-timer (* 60 60) (* 60 60) 'org-caldav-sync))
P-Takenaka commented 1 year ago

I have the same problem from time to time with a similar setup. In my case, it is oftentimes for already synced org entries for which I added a tag afterwards which is specifically excluded from the export via org-caldav-exclude-tags. The relevant entry is still present in the org file and not present in the Nextcloud calendar - as it should be. However, it is also still present in the org-caldav sync state file even though it was excluded later on. Maybe that is the issue?

Though it does not cause the error every time and you also did not use this variable in your setup, so I am not sure what the exact problem is.

My fix was to delete the local sync state files and resync everything again.

tenpast commented 1 year ago

Thanks for your comment. After writing this issue I left Emacs open with the timer running, and by the next morning it was syncing fine. Since then, I've been using org-caldav, adding tasks both on Org Mode and Nextcloud. Every now and then it complains about a missing UID, but then it eventually clears up and syncs.

It would be preferable not to get the error message, but so far it's quite usable in spite of the error.

In my case, the UID it complained about when I opened the issue was definitely for a task present in both the Org and Nextcloud calendars.

I'll post updates if I figure out what's causing this, if it becomes unusable or if I stop receiving the error.

jackkamm commented 1 year ago

@tenpast Possibly it is related to the org-mode file not being saved after sync'ing.

In last couple years, org-id changed so that it can only reliably find IDs in saved org files (it won't always find new IDs in unsaved buffers). To work around this, I added some code so that org-caldav will save the org buffer at several points during sync (e.g. after inserting new entries/IDs). However there may be some gaps -- I occasionally notice that the Org file had some unsaved changes after sync, and Org won't find the new IDs until after it's saved. Subsequent sync's will save the new changes, so maybe that's why the problem goes away.

You can try adding (org-save-all-org-buffers) after sync in your timer, to see if it fixes the issue.

tenpast commented 1 year ago

You can try adding (org-save-all-org-buffers) after sync in your timer, to see if it fixes the issue.

Thank you for the recommendation @jackkamm, I'll try this out!

jackkamm commented 1 year ago

I believe I fixed the problem in the latest commit and have closed the issue. Please re-open if you experience the problem again after updating.