From a2e3f64b673e7117f38be523e664495606dae19e Mon Sep 17 00:00:00 2001 From: artaasadi Date: Sun, 29 Dec 2024 23:36:07 +0100 Subject: [PATCH] fix: handle extract tables error --- .../job/migrations/compliance/git_parser.go | 12 ++++++++---- .../job/migrations/inventory/migrator.go | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/jobs/post-install-job/job/migrations/compliance/git_parser.go b/jobs/post-install-job/job/migrations/compliance/git_parser.go index 2d9766170..11ee108b1 100644 --- a/jobs/post-install-job/job/migrations/compliance/git_parser.go +++ b/jobs/post-install-job/job/migrations/compliance/git_parser.go @@ -274,7 +274,8 @@ func (g *GitParser) ExtractControls(complianceControlsPath string, controlEnrich } listOfTables, err := utils.ExtractTableRefsFromQuery(query.Query.QueryToExecute) if err != nil { - return err + g.logger.Error("failed to extract table refs from query", zap.String("query-id", control.ID), zap.Error(err)) + listOfTables = query.Query.ListOfTables } q := db.Query{ ID: control.ID, @@ -313,7 +314,8 @@ func (g *GitParser) ExtractControls(complianceControlsPath string, controlEnrich } else { listOfTables, err := utils.ExtractTableRefsFromQuery(control.Query.QueryToExecute) if err != nil { - return err + g.logger.Error("failed to extract table refs from query", zap.String("query-id", control.ID), zap.Error(err)) + listOfTables = control.Query.ListOfTables } q := db.Query{ @@ -796,7 +798,8 @@ func (g *GitParser) ExtractQueryViews(viewsPath string) error { listOfTables, err := utils.ExtractTableRefsFromQuery(query.Query.QueryToExecute) if err != nil { - return err + g.logger.Error("failed to extract table refs from query", zap.String("query-id", obj.ID), zap.Error(err)) + listOfTables = query.Query.ListOfTables } q := models.Query{ @@ -835,7 +838,8 @@ func (g *GitParser) ExtractQueryViews(viewsPath string) error { } else { listOfTables, err := utils.ExtractTableRefsFromQuery(obj.Query.QueryToExecute) if err != nil { - return err + g.logger.Error("failed to extract table refs from query", zap.String("query-id", obj.ID), zap.Error(err)) + listOfTables = obj.Query.ListOfTables } q := models.Query{ diff --git a/jobs/post-install-job/job/migrations/inventory/migrator.go b/jobs/post-install-job/job/migrations/inventory/migrator.go index 1c57fe005..504b93463 100644 --- a/jobs/post-install-job/job/migrations/inventory/migrator.go +++ b/jobs/post-install-job/job/migrations/inventory/migrator.go @@ -295,7 +295,8 @@ func populateFinderItem(logger *zap.Logger, tx *gorm.DB, path string, info fs.Fi } listOfTables, err := utils.ExtractTableRefsFromQuery(item.Query.QueryToExecute) if err != nil { - return err + logger.Error("failed to extract table refs from query", zap.String("query-id", dbMetric.ID), zap.Error(err)) + listOfTables = item.Query.ListOfTables } query := inventory.Query{ ID: dbMetric.ID,