Skip to content

Commit

Permalink
fix(app_generator): improve error handling for closed file I/O operat… (
Browse files Browse the repository at this point in the history
#12073)

Signed-off-by: -LAN- <[email protected]>
  • Loading branch information
laipz8200 authored Dec 25, 2024
1 parent 1885d3d commit 39ace9b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/core/app/apps/advanced_chat/app_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def _handle_advanced_chat_response(
try:
return generate_task_pipeline.process()
except ValueError as e:
if e.args[0] == "I/O operation on closed file.": # ignore this error
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
raise GenerateTaskStoppedError()
else:
logger.exception(f"Failed to process generate task pipeline, conversation_id: {conversation.id}")
Expand Down
2 changes: 1 addition & 1 deletion api/core/app/apps/message_based_app_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _handle_response(
try:
return generate_task_pipeline.process()
except ValueError as e:
if e.args[0] == "I/O operation on closed file.": # ignore this error
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
raise GenerateTaskStoppedError()
else:
logger.exception(f"Failed to handle response, conversation_id: {conversation.id}")
Expand Down
2 changes: 1 addition & 1 deletion api/core/app/apps/workflow/app_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _handle_response(
try:
return generate_task_pipeline.process()
except ValueError as e:
if e.args[0] == "I/O operation on closed file.": # ignore this error
if len(e.args) > 0 and e.args[0] == "I/O operation on closed file.": # ignore this error
raise GenerateTaskStoppedError()
else:
logger.exception(
Expand Down
2 changes: 1 addition & 1 deletion api/core/tools/tool_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def agent_invoke(
error_response = f"tool invoke error: {e}"
agent_tool_callback.on_tool_error(e)
except ToolEngineInvokeError as e:
meta = e.args[0]
meta = e.meta
error_response = f"tool invoke error: {meta.error}"
agent_tool_callback.on_tool_error(e)
return error_response, [], meta
Expand Down

0 comments on commit 39ace9b

Please sign in to comment.