From 3b218b2dc016258c9f5f9aa9e59146384612489f Mon Sep 17 00:00:00 2001 From: jiasu <57079612+jiasu-hezhip@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:40:05 +0800 Subject: [PATCH] fix:passing empty database array when updating assistant (#9570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem does this PR solve? When the `dataset_ids` parameter is omitted in the **update assistant** request, Passing an empty array `[]` triggers a misleading message"Dataset use different embedding models", while omitting the field does not. To fix this, we: - Provide a default empty list: `ids = req.get("dataset_ids", [])`. - Replace the `is not None` check with a truthy check: `if ids:`. **Files changed** `api/apps/sdk/chat.py` - L153: `ids = req.get("dataset_ids")` → `ids = req.get("dataset_ids", [])` - L156: `if ids is not None:` → `if ids:` ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/chat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/apps/sdk/chat.py b/api/apps/sdk/chat.py index 3ccaa3ab8..263375e77 100644 --- a/api/apps/sdk/chat.py +++ b/api/apps/sdk/chat.py @@ -150,10 +150,10 @@ def update(tenant_id, chat_id): if not DialogService.query(tenant_id=tenant_id, id=chat_id, status=StatusEnum.VALID.value): return get_error_data_result(message="You do not own the chat") req = request.json - ids = req.get("dataset_ids") + ids = req.get("dataset_ids", []) if "show_quotation" in req: req["do_refer"] = req.pop("show_quotation") - if ids is not None: + if ids: for kb_id in ids: kbs = KnowledgebaseService.accessible(kb_id=kb_id, user_id=tenant_id) if not kbs: