From 23522f1ea83f83831e37a065587a916cd2c6e6eb Mon Sep 17 00:00:00 2001 From: jiasu <57079612+jiasu-hezhip@users.noreply.github.com> Date: Mon, 11 Aug 2025 17:17:20 +0800 Subject: [PATCH] Fix: handle missing dataset_ids when creating chat assistant (#9324) - Root cause: accessing req.get("dataset_ids") returns None when the key is absent, causing KeyError. - Fix: use req.get("dataset_ids", []) to default to empty list. --- api/apps/sdk/chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/apps/sdk/chat.py b/api/apps/sdk/chat.py index 23231bc52..edf5e2699 100644 --- a/api/apps/sdk/chat.py +++ b/api/apps/sdk/chat.py @@ -139,7 +139,7 @@ def create(tenant_id): res["llm"] = res.pop("llm_setting") res["llm"]["model_name"] = res.pop("llm_id") del res["kb_ids"] - res["dataset_ids"] = req["dataset_ids"] + res["dataset_ids"] = req.get("dataset_ids", []) res["avatar"] = res.pop("icon") return get_result(data=res)