-
Notifications
You must be signed in to change notification settings - Fork 660
🐛 Bugfix:fix aidp search tool params' save error#3296 #3297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4ff0c5f
5ee2abb
423738c
bc60dc8
d3a8a94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,13 @@ def create_or_update_tool_by_tool_info(tool_info, tenant_id: str, user_id: str, | |
| tool_info_dict = tool_info.__dict__ | { | ||
| "tenant_id": tenant_id, "user_id": user_id, "version_no": version_no} | ||
|
|
||
| # Filter out null values from params to avoid saving nulls to database | ||
| if 'params' in tool_info_dict and tool_info_dict['params'] is not None: | ||
| tool_info_dict['params'] = { | ||
| k: v for k, v in tool_info_dict['params'].items() | ||
| if v is not None | ||
| } | ||
|
|
||
| with get_db_session() as session: | ||
| # Query if there is an existing ToolInstance | ||
| # Note: Do not filter by user_id to avoid creating duplicate instances | ||
|
|
@@ -71,7 +78,7 @@ def create_or_update_tool_by_tool_info(tool_info, tenant_id: str, user_id: str, | |
| session.add(new_tool_instance) | ||
| session.flush() # Flush to get the ID | ||
| tool_instance = new_tool_instance | ||
| return tool_instance | ||
| return as_dict(tool_instance) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 返回类型从 ORM 对象改为 dict( |
||
|
|
||
|
|
||
| def query_all_tools(tenant_id: str): | ||
|
|
@@ -258,7 +265,11 @@ def add_tool_field(tool_info): | |
| tool_params = tool.params | ||
| for ele in tool_params: | ||
| param_name = ele["name"] | ||
| ele["default"] = tool_info["params"].get(param_name) | ||
| instance_value = tool_info["params"].get(param_name) | ||
| # Only set default if instance value is not None | ||
| # This prevents null values from being saved to database and returned as defaults | ||
| if instance_value is not None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ele["default"] = instance_value | ||
| tool_dict = as_dict(tool) | ||
| tool_dict["params"] = tool_params | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1199,7 +1199,9 @@ async def update_agent_info_impl(request: AgentInfoRequest, authorization: str = | |
| if inst.get("tool_id") == tool_id), | ||
| None | ||
| ) | ||
| params = (existing_instance or {}).get("params", {}) | ||
| # Safely get params, default to empty dict if None or not present | ||
| raw_params = (existing_instance or {}).get("params") | ||
| params = raw_params if raw_params is not None else {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 防御性 None 检查是好的,但当 |
||
| create_or_update_tool_by_tool_info( | ||
| tool_info=ToolInstanceInfoRequest( | ||
| tool_id=tool_id, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
过滤 null 值的逻辑会丢失用户有意设置为 null 的默认参数。例如某个参数的 default 本身就是 None(表示"未配置"),这里会被过滤掉,导致前端无法区分"参数不存在"和"参数值为 null"。建议仅过滤显式传入的 null,而非所有 null 值。