Skip to content

Commit b802050

Browse files
committed
fix(app_generator): improve error handling for closed file I/O operat… (#12073)
Signed-off-by: -LAN- <laipz8200@outlook.com>
1 parent 1e8e020 commit b802050

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

api/core/app/apps/advanced_chat/app_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def _handle_advanced_chat_response(
380380
try:
381381
return generate_task_pipeline.process()
382382
except ValueError as e:
383-
if e.args[0] == "I/O operation on closed file.": # ignore this error
383+
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
384384
raise GenerateTaskStoppedError()
385385
else:
386386
logger.exception(f"Failed to process generate task pipeline, conversation_id: {conversation.id}")

api/core/app/apps/message_based_app_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _handle_response(
7777
try:
7878
return generate_task_pipeline.process()
7979
except ValueError as e:
80-
if e.args[0] == "I/O operation on closed file.": # ignore this error
80+
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
8181
raise GenerateTaskStoppedError()
8282
else:
8383
logger.exception(f"Failed to handle response, conversation_id: {conversation.id}")

api/core/app/apps/workflow/app_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def _handle_response(
309309
try:
310310
return generate_task_pipeline.process()
311311
except ValueError as e:
312-
if e.args[0] == "I/O operation on closed file.": # ignore this error
312+
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
313313
raise GenerateTaskStoppedError()
314314
else:
315315
logger.exception(

api/core/tools/tool_engine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def agent_invoke(
111111
error_response = f"tool invoke error: {e}"
112112
agent_tool_callback.on_tool_error(e)
113113
except ToolEngineInvokeError as e:
114-
meta = e.args[0]
114+
meta = e.meta
115115
error_response = f"tool invoke error: {meta.error}"
116116
agent_tool_callback.on_tool_error(e)
117117
return error_response, [], meta

0 commit comments

Comments
 (0)