fix: do not enqueue Google Calendar sync when export is disabled (closes #2040)#2053
Open
ther12k wants to merge 1 commit into
Open
fix: do not enqueue Google Calendar sync when export is disabled (closes #2040)#2053ther12k wants to merge 1 commit into
ther12k wants to merge 1 commit into
Conversation
… (issue callumalpass#2040) When a user installed TaskNotes and created tasks without ever enabling the Google Calendar export integration, every eligible task (those with a scheduled or due date) would append an entry to googleCalendarSyncQueue in data.json. The queue was being populated with entries like: 'lastError': 'Google Calendar sync is not ready' This happened because: 1. TaskCreationService calls syncTaskToCalendar for every task when googleCalendarExport.syncOnTaskCreate === true. 2. syncTaskToCalendar passes the eligibility check (any task with scheduled/due is eligible per settings.googleCalendarExport.syncTrigger). 3. syncTaskToCalendar reaches the 'if (!this.isEnabled())' branch. 4. isEnabled() returns false because the user never configured the integration, so queueTaskSync is called with 'sync not ready'. 5. The queue entry is persisted to data.json. 6. Nothing ever clears it because the queue is intended for transient failures that the recovery loop processes; a permanent 'never configured' state never recovers. The queue is for transient failures (auth expired, rate limited, target calendar temporarily missing). When the user has opted out of the feature entirely, there is nothing to recover from. Fix: add an early-return at the top of syncTaskToCalendar when settings.googleCalendarExport.enabled === false. This applies to every caller (TaskCreationService, taskNotesCommands, TaskContextMenu, the periodic sync loop) without needing a guard at each call site. The existing isEnabled() check below is preserved unchanged so that transient failures while the feature IS enabled still queue as before. Adds tests/unit/issues/issue-2040-google-calendar-sync-queue.test.ts with three cases: - export disabled → syncTaskToCalendar returns true, queueTaskSync not called - export enabled but isEnabled() false (e.g. OAuth disconnected) → queueTaskSync IS called (preserves existing behavior) - ineligible task + export disabled → no-op, no queue interaction Closes callumalpass#2040
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2040.
Root cause
syncTaskToCalendarinsrc/services/TaskCalendarSyncService.tsenqueues entries intogoogleCalendarSyncQueueeven whensettings.googleCalendarExport.enabled === false. The check happens later in the pipeline, after the queue interaction, so disabled users see queue churn and retry attempts they never asked for.Fix
Early-return at the top of
syncTaskToCalendarwhensettings.googleCalendarExport.enabled === false, before any queue interaction. Transient-failure queueing for users who do have export enabled is preserved.Tests
tests/unit/issues/issue-2040-google-calendar-sync-queue.test.ts:Notes