A local-first personal finance app
[AI] Show a clear error when the API finds an out-of-sync local budget (#9393)
bubbletroublesf2cc89778255
diff --git a/packages/loot-core/src/shared/errors.test.ts b/packages/loot-core/src/shared/errors.test.tsindex e4d67423ae..801e5c012f 100644--- a/packages/loot-core/src/shared/errors.test.ts+++ b/packages/loot-core/src/shared/errors.test.ts@@ -60,4 +60,16 @@ describe('getSyncError', () => {SCHEMA_MISMATCH_MESSAGE,);});++ it('explains how to recover from an out-of-sync local budget', () => {+ expect(getSyncError('out-of-sync', 'budget-id')).toBe(+ 'The local copy of budget "budget-id" is out of sync with the server. Delete the "budget-id" folder from your data directory and download the budget again (any changes not yet synced to the server will be lost).',+ );+ });++ it('falls back to the generic message for unknown errors', () => {+ expect(getSyncError('something-else', 'budget-id')).toBe(+ 'We had an unknown problem opening "budget-id".',+ );+ });});diff --git a/packages/loot-core/src/shared/errors.ts b/packages/loot-core/src/shared/errors.tsindex 219365c182..dbc622de62 100644--- a/packages/loot-core/src/shared/errors.ts+++ b/packages/loot-core/src/shared/errors.ts@@ -163,6 +163,8 @@ export function getSyncError(error: string, id: string, meta?: unknown) {return `Budget "${id}" not found. Check the ID of your budget in the Advanced section of the settings page.`;} else if (error === 'clock-drift') {return 'Failed to sync because your device time differs too much from the server. Please check your device time settings and ensure they are correct.';+ } else if (error === 'out-of-sync') {+ return `The local copy of budget "${id}" is out of sync with the server. Delete the "${id}" folder from your data directory and download the budget again (any changes not yet synced to the server will be lost).`;} else {return `We had an unknown problem opening "${id}".`;}diff --git a/upcoming-release-notes/fix-api-out-of-sync-error.md b/upcoming-release-notes/fix-api-out-of-sync-error.mdnew file mode 100644index 0000000000..3601dce3aa--- /dev/null+++ b/upcoming-release-notes/fix-api-out-of-sync-error.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [bubbletroubles]+---++Show a clear error with recovery steps when the API finds a budget that is out of sync with the server.