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 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-22 23:02:16 +01:00
parent ba19482a41
commit 87d78d78b5
2 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "my-weekly-todo-list", "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", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -206,7 +206,20 @@ export async function GET(req: NextRequest) {
} }
} }
} catch (listError: any) { } 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`); console.warn(`Google Tasks quota exceeded for list ${listId}, skipping`);
} else { } else {
console.error(`Error syncing Google list ${listId}:`, listError); console.error(`Error syncing Google list ${listId}:`, listError);