From 87d78d78b5b63b1f0eefd6d96920a7891c0401f3 Mon Sep 17 00:00:00 2001 From: mARTin Date: Sun, 22 Mar 2026 23:02:16 +0100 Subject: [PATCH] fix: handle deleted Google Tasks lists gracefully (404 cleanup) When a Google Tasks list returns 404 during sync, soft-delete all local tasks linked to it and unlink the synced someday list instead of spamming error logs. v1.57.3 Co-Authored-By: Claude Opus 4.6 --- package.json | 2 +- src/app/api/tasks/sync/route.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index de693fb..4993532 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.57.2", + "version": "1.57.3", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/app/api/tasks/sync/route.ts b/src/app/api/tasks/sync/route.ts index 91775d6..396782a 100644 --- a/src/app/api/tasks/sync/route.ts +++ b/src/app/api/tasks/sync/route.ts @@ -206,7 +206,20 @@ export async function GET(req: NextRequest) { } } } catch (listError: any) { - if (listError?.code === 429 || listError?.status === 429) { + if (listError?.code === 404 || listError?.status === 404) { + console.warn(`Google Tasks list ${listId} not found (deleted?), cleaning up local references`); + // Soft-delete local tasks linked to this deleted list + const result = await prisma.task.updateMany({ + where: { userId: user.id, externalProvider: 'google', externalListId: listId, deletedAt: null }, + data: { deletedAt: new Date() }, + }); + deleted += result.count; + // Unlink the synced someday list + await prisma.somedayList.updateMany({ + where: { userId: user.id, externalProvider: 'google', externalId: listId }, + data: { externalId: null, externalProvider: null }, + }); + } else if (listError?.code === 429 || listError?.status === 429) { console.warn(`Google Tasks quota exceeded for list ${listId}, skipping`); } else { console.error(`Error syncing Google list ${listId}:`, listError);