From c0cd2373c0be88a53c5544216e0c1601a8e36b36 Mon Sep 17 00:00:00 2001 From: lanceyq <1982376970@qq.com> Date: Mon, 30 Mar 2026 15:51:30 +0800 Subject: [PATCH] [fix] Added type checking with isinstance(a, str) and filtering out empty strings with a.strip() --- api/app/services/user_memory_service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api/app/services/user_memory_service.py b/api/app/services/user_memory_service.py index c6743ff2..ab51d922 100644 --- a/api/app/services/user_memory_service.py +++ b/api/app/services/user_memory_service.py @@ -480,9 +480,12 @@ class UserMemoryService: logger.warning(f"拒绝将占位名称 '{update_data['other_name']}' 设置为 other_name") del update_data['other_name'] - # 过滤 aliases:移除占位名称 + # 过滤 aliases:移除占位名称和非字符串值 if 'aliases' in update_data and update_data['aliases']: - update_data['aliases'] = [a for a in update_data['aliases'] if a.strip() not in _user_placeholder_names] + update_data['aliases'] = [ + a for a in update_data['aliases'] + if isinstance(a, str) and a.strip() and a.strip() not in _user_placeholder_names + ] # 检查是否更新了 aliases 字段 aliases_updated = 'aliases' in update_data and update_data['aliases'] != end_user_info_record.aliases