Skip to content

Preserve id for reminders in sectioned lists#53

Merged
ajrosen merged 1 commit intoajrosen:mainfrom
tilthouse:aboster/preserve-id-on-sectioned-lists
Apr 26, 2026
Merged

Preserve id for reminders in sectioned lists#53
ajrosen merged 1 commit intoajrosen:mainfrom
tilthouse:aboster/preserve-id-on-sectioned-lists

Conversation

@tilthouse
Copy link
Copy Markdown
Contributor

Summary

Reminder#initialize deletes the CloudKit identifier (zckIdentifier, exposed as id) from any reminder that belongs to a sectioned list.

The deletion lives in the if @self['members'] block alongside a necessary delete('members'), but the section lookup only needs id locally — there's no reason to strip it from the output.

In practice this affects ~85% of reminders on a typical user's data, because every Apple grocery list uses sections, plus any user list with sections configured by the user. Downstream consumers that need the identifier for joins or deduplication silently receive null.

The fix

One-line change in lib/reminder.rb: drop the @self.delete('id') call inside the section-handling block. members is still deleted (it's an internal JSON membership table). A short comment is added to discourage anyone re-adding the deletion.

# Before
@self.delete('members')
@self.delete('id')

# After
# Drop the internal membership scratch but keep `id` (zckIdentifier),
# which downstream consumers rely on for joins/dedup.
@self.delete('members')

Tests

Adds test/reminder_id_test.rb — 4 cases using stdlib minitest:

  • id is preserved when the reminder belongs to a sectioned list (the regression case)
  • id is preserved when the reminder is not in a sectioned list (control)
  • members is still dropped from output (preserves existing behavior)
  • Section lookup still resolves correctly (the lookup uses id internally; restoring id to output doesn't interfere)

Run with:

ruby test/reminder_id_test.rb

I confirmed the suite catches the regression — reverting the one-line fix produces 2 failures (cases 1 and 4).

Notes

  • No changes to runtime dependencies, gemspec, or executable surface.
  • Rubocop clean against the project's .rubocop.yml.
  • Happy to adjust the comment, test layout, or commit message to match maintainer preferences.

`Reminder#initialize` deleted the CloudKit identifier (`zckIdentifier`,
exposed as `id`) from any reminder that belonged to a sectioned list.
The deletion was inside the `if @self['members']` block alongside a
necessary `delete('members')`, but the section lookup only needs `id`
locally — there's no reason to strip it from the output.

In practice this affected ~85% of reminders on a typical user's data,
because every Apple grocery list uses sections, plus any user list with
sections configured. Downstream consumers that need the identifier for
joins or deduplication silently received `null`.

Add a regression test under test/ using stdlib minitest.
@ajrosen ajrosen merged commit 09cb09c into ajrosen:main Apr 26, 2026
1 check passed
@ajrosen
Copy link
Copy Markdown
Owner

ajrosen commented Apr 26, 2026

I don't remember why I stripped it out, but you're right, there's no reason not to keep it in. And the events and calendars commands have it, so tasks should too.

I'll also add an alias for it called UUID to be consitent with the other commands.

I'm curious what kinds of joins or dedups are being done from the output?

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.

2 participants