From ded45ae9c23ae97983109168e3e70470e3eecfa0 Mon Sep 17 00:00:00 2001 From: Lynwee <1507509064@qq.com> Date: Wed, 30 Oct 2024 17:07:46 +0800 Subject: [PATCH] feat(tapd): add more log when converting unicode (#8164) * feat(tapd): add more log when converting unicode * feat(tapd): ignore errors when converting unicode fails --- backend/plugins/tapd/tasks/bug_changelog_extractor.go | 5 ++++- backend/plugins/tapd/tasks/story_changelog_extractor.go | 5 +++-- backend/plugins/tapd/tasks/task_changelog_extractor.go | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/plugins/tapd/tasks/bug_changelog_extractor.go b/backend/plugins/tapd/tasks/bug_changelog_extractor.go index e50d2b44298..8757e5aa0ea 100644 --- a/backend/plugins/tapd/tasks/bug_changelog_extractor.go +++ b/backend/plugins/tapd/tasks/bug_changelog_extractor.go @@ -38,6 +38,7 @@ var ExtractBugChangelogMeta = plugin.SubTaskMeta{ func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error { rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_BUG_CHANGELOG_TABLE) + logger := taskCtx.GetLogger() extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ RawDataSubTaskArgs: *rawDataSubTaskArgs, Extract: func(row *api.RawData) ([]interface{}, errors.Error) { @@ -47,6 +48,7 @@ func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err := errors.Convert(json.Unmarshal(row.Data, &bugChangelogBody)) if err != nil { + logger.Error(err, "unmarshal: %s, err: %s", row.Data, err) return nil, err } bugChangelog := bugChangelogBody.BugChange @@ -62,11 +64,12 @@ func ExtractBugChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err = convertUnicode(item) if err != nil { - return nil, err + logger.Error(err, "convert unicode: %s, err: %s", item, err) } if item.Field == "iteration_id" { iterationFrom, iterationTo, err := parseIterationChangelog(taskCtx, item.ValueBeforeParsed, item.ValueAfterParsed) if err != nil { + logger.Error(err, "parseIterationChangelog: %s, err: %s", item, err) return nil, err } item.IterationIdFrom = iterationFrom diff --git a/backend/plugins/tapd/tasks/story_changelog_extractor.go b/backend/plugins/tapd/tasks/story_changelog_extractor.go index 62c09ea7229..667e833ccee 100644 --- a/backend/plugins/tapd/tasks/story_changelog_extractor.go +++ b/backend/plugins/tapd/tasks/story_changelog_extractor.go @@ -36,6 +36,7 @@ var ExtractStoryChangelogMeta = plugin.SubTaskMeta{ } func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error { + logger := taskCtx.GetLogger() rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_STORY_CHANGELOG_TABLE) extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ RawDataSubTaskArgs: *rawDataSubTaskArgs, @@ -89,7 +90,7 @@ func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err = convertUnicode(&item) if err != nil { - return nil, err + logger.Error(err, "convert unicode: %s, err: %s", item, err) } results = append(results, &item) } @@ -103,7 +104,7 @@ func ExtractStoryChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err = convertUnicode(&item) if err != nil { - return nil, err + logger.Error(err, "convert unicode: %s, err: %s", item, err) } if item.Field == "iteration_id" { // some users' tapd will not return iteration_id_from/iteration_id_to diff --git a/backend/plugins/tapd/tasks/task_changelog_extractor.go b/backend/plugins/tapd/tasks/task_changelog_extractor.go index 1ccfd147973..df9834b3724 100644 --- a/backend/plugins/tapd/tasks/task_changelog_extractor.go +++ b/backend/plugins/tapd/tasks/task_changelog_extractor.go @@ -38,6 +38,7 @@ var ExtractTaskChangelogMeta = plugin.SubTaskMeta{ func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error { rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_TASK_CHANGELOG_TABLE) + logger := taskCtx.GetLogger() extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{ RawDataSubTaskArgs: *rawDataSubTaskArgs, Extract: func(row *api.RawData) ([]interface{}, errors.Error) { @@ -92,7 +93,7 @@ func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err = convertUnicode(&item) if err != nil { - return nil, err + logger.Error(err, "convert unicode: %s, err: %s", item, err) } default: item.ConnectionId = data.Options.ConnectionId @@ -103,7 +104,7 @@ func ExtractTaskChangelog(taskCtx plugin.SubTaskContext) errors.Error { } err = convertUnicode(&item) if err != nil { - return nil, err + logger.Error(err, "convert unicode: %s, err: %s", item, err) } if item.Field == "iteration_id" { iterationFrom, iterationTo, err := parseIterationChangelog(taskCtx, item.ValueBeforeParsed, item.ValueAfterParsed)