From daaf33bc5b7210751c517b063f54fa1dfee81d0a Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 18 Dec 2024 15:12:01 +0800 Subject: [PATCH] fix: fixed the null pointer when an audit error occurred in the audit plan --- sqle/server/auditplan/job_task_handler.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sqle/server/auditplan/job_task_handler.go b/sqle/server/auditplan/job_task_handler.go index e112a6122..32b41599c 100644 --- a/sqle/server/auditplan/job_task_handler.go +++ b/sqle/server/auditplan/job_task_handler.go @@ -87,7 +87,6 @@ func BatchAuditSQLs(l *logrus.Entry, sqlList []*model.SQLManageRecord) ([]*model var resp *AuditResultResp meta, err := GetMeta(sourceType) - // 当无法获取meta时,不执行审核,直接返回原始sql if err != nil { l.Errorf("get meta to audit sql fail %v", err) } else { @@ -106,7 +105,12 @@ func BatchAuditSQLs(l *logrus.Entry, sqlList []*model.SQLManageRecord) ([]*model } } mu.Lock() - auditedSQLs = append(auditedSQLs, resp.AuditedSqls...) + // 当审核结果不为nil时,从审核结果中获取sql,其他错误情况直接返回原始sql + if resp != nil { + auditedSQLs = append(auditedSQLs, resp.AuditedSqls...) + } else { + auditedSQLs = append(auditedSQLs, sqls...) + } mu.Unlock() }(sqls) }