Skip to content

fix(pim): keep what Google's sync calls deleted but still serves - #46

Merged
bketelsen merged 1 commit into
mainfrom
claude/sad-gould-12b643
Oct 15, 2026
Merged

bketelsen merged 1 commit into
mainfrom
claude/sad-gould-12b643

Conversation

@bketelsen

Copy link
Copy Markdown
Contributor

Summary

mailctl verify 4 showed the user's main Gmail calendar as DIFFERS: 1384 objects on the server, 1382 stored, with two missing locally. Sync never stored them, and it said nothing about them.

Cause. Google's CalDAV sync-collection calls both hrefs deleted (404), from no token and again in later deltas. Its PROPFIND, a calendar-multiget and a GET all still serve them. Both are single occurrences whose series is gone: a VEVENT with a RECURRENCE-ID and no master, which calendar.Parse/Expand already handle. Sync followed the sync-collection report. tools/davprobe showed that 25 of the hrefs a full sync calls deleted remain, and Google serves exactly these two of them.

Fix. Sync stores them; verify keeps counting them, since Google Calendar shows them.

  • providers.DAV.ServesDeleted (set for Gmail): on such a server, syncCollection adds every href a sync calls deleted to the multiget. It stores what comes back, and fetchDAV removes what doesn't. Other servers behave as before, so contract tests stand.
  • Migration 0016 clears Gmail calendars' sync_token/ctag once. The next pass lists them in full and fetches only what is missing or has a different ETag.
  • davtest.HideFromSync imitates Google. TestServedObjectsCalledDeleted covers a Gmail account through first sync, a change and a real deletion. It also covers a generic account, which follows its sync and reproduces the bug. TestMigration16ListsGmailCalendarsAgain covers the migration.
  • tools/davprobe is a read-only diagnostic. It compares sync-collection (no token, stored token, -token), PROPFIND and a multiget against the store.
  • docs/design/pim.md describes the fix. Its Oct 9 note had accepted this gap.

Test plan

  • make check: gofmt, vet, golangci-lint with 0 issues, unit tests including the Google replay, and the fork's tests
  • The new test fails without the fix: Server 2, Local 1, review.ics missing locally
  • Read-only end-to-end run on a snapshot of the user's DB (pim_ops emptied, account read_only = 1, HTTP refusing all but GET/PROPFIND/REPORT): after migration 0016 and one pass, verify was clean for every collection of account 4, with "Brian Ketelsen" at 1384/1384. Both objects were indexed as single occurrences with no parse error.
  • After merge: rebuild and restart maild, then mailctl verify 4 is clean

🤖 Generated with Claude Code

Google's CalDAV sync-collection calls some objects deleted, from no token
as well, that its PROPFIND, a multiget and a GET still serve: single
occurrences whose series is gone (a VEVENT with a RECURRENCE-ID and no
master). Sync followed the sync and never stored them, so verify on the
user's Gmail calendar showed 1384 on the server and 1382 here.

A Gmail pass now asks for every href its sync calls deleted (the
profile's new DAV.ServesDeleted), stores what the server sends and
removes the rest. Migration 0016 clears Gmail calendars' sync state so
the next pass lists them again and fetches the ones missed before.
tools/davprobe compares, read-only, what sync-collection, PROPFIND and a
multiget say of a collection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bketelsen
bketelsen merged commit c5ab320 into main Oct 15, 2026
4 checks passed
@bketelsen
bketelsen deleted the claude/sad-gould-12b643 branch October 15, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant