Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix handling of missing required parameters in ApiTool (#2965)

Yulong Wang8e052615880d
diff --git a/api/core/tools/tool/api_tool.py b/api/core/tools/tool/api_tool.py
index 54e2f410191..ab46dc61da1 100644
--- a/api/core/tools/tool/api_tool.py
+++ b/api/core/tools/tool/api_tool.py
@@ -148,7 +148,7 @@ class ApiTool(Tool):
value = ''
if parameter['name'] in parameters:
value = parameters[parameter['name']]
- elif parameter['required']:
+ elif parameter.get('required', False):
raise ToolParameterValidationError(f"Missing required parameter {parameter['name']}")
else:
value = (parameter.get('schema', {}) or {}).get('default', '')
@@ -158,7 +158,7 @@ class ApiTool(Tool):
value = ''
if parameter['name'] in parameters:
value = parameters[parameter['name']]
- elif parameter['required']:
+ elif parameter.get('required', False):
raise ToolParameterValidationError(f"Missing required parameter {parameter['name']}")
else:
value = (parameter.get('schema', {}) or {}).get('default', '')
@@ -168,7 +168,7 @@ class ApiTool(Tool):
value = ''
if parameter['name'] in parameters:
value = parameters[parameter['name']]
- elif parameter['required']:
+ elif parameter.get('required', False):
raise ToolParameterValidationError(f"Missing required parameter {parameter['name']}")
else:
value = (parameter.get('schema', {}) or {}).get('default', '')