diff --git a/common/auth.py b/common/auth.py index 40b1dde10e..bae340f8aa 100644 --- a/common/auth.py +++ b/common/auth.py @@ -71,7 +71,7 @@ def authenticate(self): except: logger.error('验证用户密码时报错') logger.error(traceback.format_exc()) - return {'status': 1, 'msg': f'服务器错误{traceback.format_exc()}', 'data': ''} + return {'status': 1, 'msg': f'服务异常,请联系管理员处理', 'data': ''} # 已存在用户, 验证是否在锁期间 # 读取配置文件 lock_count = int(self.sys_config.get('lock_cnt_threshold', 5)) diff --git a/sql/utils/execute_sql.py b/sql/utils/execute_sql.py index 988fdee58e..0ba93436c2 100644 --- a/sql/utils/execute_sql.py +++ b/sql/utils/execute_sql.py @@ -1,4 +1,6 @@ # -*- coding: UTF-8 -*- +import logging +import traceback from django.db import close_old_connections, connection, transaction from django_redis import get_redis_connection @@ -10,6 +12,8 @@ from sql.utils.workflow_audit import Audit from sql.engines import get_engine +logger = logging.getLogger('default') + def execute(workflow_id, user=None): """为延时或异步任务准备的execute, 传入工单ID和执行人信息""" @@ -69,11 +73,19 @@ def execute_callback(task): else: execute_result = task.result workflow.status = 'workflow_finish' - # 保存执行结果 - workflow.sqlworkflowcontent.execute_result = execute_result.json() - workflow.sqlworkflowcontent.save() - workflow.save() - + try: + # 保存执行结果 + workflow.sqlworkflowcontent.execute_result = execute_result.json() + workflow.sqlworkflowcontent.save() + workflow.save() + except Exception as e: + logger.error(f'SQL工单回调异常: {workflow_id} {traceback.format_exc()}') + SqlWorkflow.objects.filter(id=workflow_id).update( + finish_time=task.stopped, + status='workflow_exception', + ) + workflow.sqlworkflowcontent.execute_result = {f'{e}'} + workflow.sqlworkflowcontent.save() # 增加工单日志 audit_id = Audit.detail_by_workflow_id(workflow_id=workflow_id, workflow_type=WorkflowDict.workflow_type['sqlreview']).audit_id diff --git a/sql_api/views.py b/sql_api/views.py index 3c400f592e..a293adf15d 100644 --- a/sql_api/views.py +++ b/sql_api/views.py @@ -43,6 +43,14 @@ def debug(request): # 系统配置 sys_config = SysConfig().sys_config + # 敏感信息处理 + secret_keys = [ + 'inception_remote_backup_password', + 'ding_app_secret', + 'feishu_app_secret', + 'mail_smtp_password' + ] + sys_config.update({k: "******" for k in secret_keys}) # MySQL信息 cursor = connection.cursor()