Bug Fix where - in exceptional cases - a connection without correct search path could be used (out of the connection pool).

This commit is contained in:
Josako
2025-10-24 11:42:50 +02:00
parent a43825f5f0
commit b3ee2f7ce9
3 changed files with 115 additions and 12 deletions

View File

@@ -351,16 +351,27 @@ def execute_specialist(self, tenant_id: int, specialist_id: int, arguments: Dict
return response
except Exception as e:
# Ensure DB session is usable after an error
try:
db.session.rollback()
except Exception:
pass
stacktrace = traceback.format_exc()
ept.send_update(task_id, "EveAI Specialist Error", {'Error': str(e)})
current_app.logger.error(f'execute_specialist: Error executing specialist: {e}\n{stacktrace}')
new_interaction.processing_error = str(e)[:255]
try:
db.session.add(new_interaction)
db.session.commit()
except SQLAlchemyError as e:
stacktrace = traceback.format_exc()
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}\n{stacktrace}')
if new_interaction is not None:
new_interaction.processing_error = str(e)[:255]
try:
db.session.add(new_interaction)
db.session.commit()
except SQLAlchemyError as e:
# On failure to update, rollback and log
try:
db.session.rollback()
except Exception:
pass
stacktrace = traceback.format_exc()
current_app.logger.error(f'execute_specialist: Error updating interaction: {e}\n{stacktrace}')
self.update_state(state=states.FAILURE)
raise