Skip to content

Commit d5eb836

Browse files
KrisBraunclaude
andcommitted
connector-apple-calendar: defer etag write until event processing succeeds
Follow-up to ad61247. Per-event parse failure (caught at the try/catch inside processCalDAVEvents loop) would still leave that event's etag in the persistent map with no corresponding uid, recreating the bug the prior commit fixed but at a much narrower failure rate. Move the etag write to the end of the per-event try block so the etag is only recorded when the uid was also recorded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ad61247 commit d5eb836

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎connectors/apple-calendar/src/apple-calendar.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,14 +715,6 @@ export class AppleCalendar extends Connector<AppleCalendar> {
715715
let etagMapDirty = false;
716716

717717
for (const caldavEvent of events) {
718-
// Record the etag up-front for every event in this batch so the
719-
// stored set matches the uids we're about to record. Both maps are
720-
// persisted together below.
721-
if (etagMap[caldavEvent.href] !== caldavEvent.etag) {
722-
etagMap[caldavEvent.href] = caldavEvent.etag;
723-
etagMapDirty = true;
724-
}
725-
726718
try {
727719
const icsEvents = parseICSEvents(caldavEvent.icsData);
728720

@@ -751,6 +743,14 @@ export class AppleCalendar extends Connector<AppleCalendar> {
751743
);
752744
}
753745
}
746+
747+
// Record etag only after the per-event work succeeds so a parse
748+
// failure can't leave an etag without a uid (which would later
749+
// surface as a `missingUid` skip on deletion).
750+
if (etagMap[caldavEvent.href] !== caldavEvent.etag) {
751+
etagMap[caldavEvent.href] = caldavEvent.etag;
752+
etagMapDirty = true;
753+
}
754754
} catch (error) {
755755
console.error(
756756
`Error processing CalDAV event ${caldavEvent.href}:`,

0 commit comments

Comments
 (0)