From f338f7b102e538889e4f16fac407f4d5f17fdf69 Mon Sep 17 00:00:00 2001 From: xuatz Date: Sun, 18 May 2025 01:51:46 +0900 Subject: fix(api): make PUT bookmark to a list idempotent (#1427) * fix(api): make duplicate PUT /lists/:id/bookmarks/:id as allowed operation * apply pr comments --- packages/trpc/models/lists.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'packages/trpc/models/lists.ts') diff --git a/packages/trpc/models/lists.ts b/packages/trpc/models/lists.ts index 4da127d2..21b23593 100644 --- a/packages/trpc/models/lists.ts +++ b/packages/trpc/models/lists.ts @@ -260,10 +260,8 @@ export class ManualList extends List { } catch (e) { if (e instanceof SqliteError) { if (e.code == "SQLITE_CONSTRAINT_PRIMARYKEY") { - throw new TRPCError({ - code: "BAD_REQUEST", - message: `Bookmark ${bookmarkId} is already in the list ${this.list.id}`, - }); + // this is fine, it just means the bookmark is already in the list + return; } } throw new TRPCError({ -- cgit v1.2.3-70-g09d2