From c306a7e16ee92e64b56e89fd1d15d2ac90437741 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 19 May 2026 19:03:58 +0200 Subject: [PATCH] refactor: remove unused DELETE /chats/{id}/tags/all endpoint (#24785) The bulk-clear-chat-tags endpoint's only frontend wrapper, deleteTagsById in src/lib/apis/chats/index.ts, is dead: nothing imports or calls it, the path is referenced nowhere else, and the route handler has no internal caller. Removes the route handler, the dead wrapper, and the now-orphaned Chats.delete_all_tags_by_id_and_user_id model method (its sole caller was this route). The shared Chats.delete_orphan_tags_for_user method is untouched. Co-authored-by: Claude Opus 4.7 (1M context) --- backend/open_webui/models/chats.py | 14 ------------- backend/open_webui/routers/chats.py | 20 ------------------- src/lib/apis/chats/index.ts | 31 ----------------------------- 3 files changed, 65 deletions(-) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index a19cdf1a6b..4a40a049a0 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -1514,20 +1514,6 @@ class ChatTable: except Exception: return False - async def delete_all_tags_by_id_and_user_id(self, id: str, user_id: str, db: AsyncSession | None = None) -> bool: - try: - async with get_async_db_context(db) as db: - chat = await db.get(Chat, id) - chat.meta = { - **chat.meta, - 'tags': [], - } - await db.commit() - - return True - except Exception: - return False - async def delete_chat_by_id(self, id: str, db: AsyncSession | None = None) -> bool: try: async with get_async_db_context(db) as db: diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 7c6f3dea9d..4fdde37200 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -1591,23 +1591,3 @@ async def delete_tag_by_id_and_tag_name( return await Tags.get_tags_by_ids_and_user_id(tags, user.id, db=db) else: raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.NOT_FOUND) - - -############################ -# DeleteAllTagsById -############################ - - -@router.delete('/{id}/tags/all', response_model=bool | None) -async def delete_all_tags_by_id( - id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session) -): - chat = await Chats.get_chat_by_id_and_user_id(id, user.id, db=db) - if chat: - old_tags = chat.meta.get('tags', []) - await Chats.delete_all_tags_by_id_and_user_id(id, user.id, db=db) - await Chats.delete_orphan_tags_for_user(old_tags, user.id, db=db) - - return True - else: - raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=ERROR_MESSAGES.NOT_FOUND) diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 48f1a4812d..1916e35086 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -1206,37 +1206,6 @@ export const deleteTagById = async (token: string, id: string, tagName: string) return res; }; -export const deleteTagsById = async (token: string, id: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}/tags/all`, { - method: 'DELETE', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - } - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .then((json) => { - return json; - }) - .catch((err) => { - error = err; - - console.error(err); - return null; - }); - - if (error) { - throw error; - } - - return res; -}; export const deleteAllChats = async (token: string) => { let error = null;