From 36cc531d972814f05fbd7baaeab7d4ff1689d7c7 Mon Sep 17 00:00:00 2001 From: martin-forge <228563004+martin-forge@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:52:48 +0100 Subject: [PATCH 1/2] fix: stop startup when an existing settings file cannot be read --- docs/releases/unreleased.md | 3 +++ src/main.ts | 4 ++++ tests/unit/issues/issue-1591-settings-lost-on-update.test.ts | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index c29cde0dd..848c6059e 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -34,6 +34,9 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l ## Fixed +- Stop plugin startup when an existing settings file cannot be read, preserving it for recovery instead of starting services with default settings. + - Thanks to @martin-forge for the contribution. + - (#1849) Fixed context menus stacking on top of each other. Only one menu stays open at a time, and clicking the same indicator again closes its menu. This previously applied to date fields only, and now covers priority, status, recurrence, reminders, task, ICS event, and batch menus. - Thanks to @3zra47 for reporting and @YBKF for the contribution. diff --git a/src/main.ts b/src/main.ts index 4a967ff72..d1fe8ad43 100644 --- a/src/main.ts +++ b/src/main.ts @@ -744,6 +744,10 @@ export default class TaskNotesPlugin extends Plugin { }, }); } + if (result.compromised) + throw new Error( + "TaskNotes settings are unreadable; restore settings before loading the plugin." + ); return result.data; } diff --git a/tests/unit/issues/issue-1591-settings-lost-on-update.test.ts b/tests/unit/issues/issue-1591-settings-lost-on-update.test.ts index bcd377f6e..4f151779d 100644 --- a/tests/unit/issues/issue-1591-settings-lost-on-update.test.ts +++ b/tests/unit/issues/issue-1591-settings-lost-on-update.test.ts @@ -38,8 +38,8 @@ describe("issue #1591 settings reset on update", () => { const plugin = createPlugin({ dataFileExists: true }); plugin.loadData = jest.fn().mockResolvedValue(null); - await plugin.loadSettings(); - await plugin.checkForVersionUpdate(); + await expect(plugin.loadSettings()).rejects.toThrow("settings are unreadable"); + await plugin.saveSettingsDataOnly(); expect(plugin.loadData).toHaveBeenCalledTimes(4); expect(plugin.saveData).not.toHaveBeenCalled(); From bbf53a0bb0dd6168ad1b3e6d7a49f15d75d48bed Mon Sep 17 00:00:00 2001 From: martin-forge <228563004+martin-forge@users.noreply.github.com> Date: Sat, 5 Sep 2026 18:22:43 +0100 Subject: [PATCH 2/2] Remove self-attribution from release note --- docs/releases/unreleased.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index 848c6059e..6bcd3b76b 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -35,7 +35,6 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l ## Fixed - Stop plugin startup when an existing settings file cannot be read, preserving it for recovery instead of starting services with default settings. - - Thanks to @martin-forge for the contribution. - (#1849) Fixed context menus stacking on top of each other. Only one menu stays open at a time, and clicking the same indicator again closes its menu. This previously applied to date fields only, and now covers priority, status, recurrence, reminders, task, ICS event, and batch menus. - Thanks to @3zra47 for reporting and @YBKF for the contribution.