From add05d9a9385976f581226062d18a4c97c430ee3 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:08:04 +0530 Subject: [PATCH] fix(zentao): store bug severity as its decimal string The bug converter set issues.severity with string(rune(severity)), which turns severity 3 into the control character U+0003 instead of "3". Format it with strconv.Itoa through a getSeverity helper next to getPriority, and fix the \x03 bytes in the e2e snapshots. Closes #9380 Generated-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com> --- .../zentao/e2e/snapshot_tables/issues_bug.csv | 12 ++++++------ .../snapshot_tables/issues_bug_for_due_date.csv | 2 +- backend/plugins/zentao/tasks/bug_convertor.go | 2 +- backend/plugins/zentao/tasks/shared.go | 6 ++++++ backend/plugins/zentao/tasks/shared_test.go | 17 +++++++++++++++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv index d15bec1c87a..76843f1d3e9 100644 --- a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv +++ b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug.csv @@ -1,7 +1,7 @@ id,url,icon_url,issue_key,title,description,epic_key,type,original_type,status,original_status,story_point,resolution_date,created_date,updated_date,lead_time_minutes,original_estimate_minutes,time_spent_minutes,time_remaining_minutes,creator_id,creator_name,assignee_id,assignee_name,parent_issue_id,priority,severity,urgency,component,is_subtask,due_date -zentao:ZentaoBug:1:1,http://iwater.red:8000/bug-view-1.html,,1,首页页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:56:11.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:1,1,,,,0, -zentao:ZentaoBug:1:2,http://iwater.red:8000/bug-view-2.html,,2,新闻中心页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,,,zentao:ZentaoStory:1:2,2,,,,0,2022-10-05T16:00:00.000+00:00 -zentao:ZentaoBug:1:3,http://iwater.red:8000/bug-view-3.html,,3,成果展示页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:58:22.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:8,测试乙,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:3,1,,,,0, -zentao:ZentaoBug:1:4,http://iwater.red:8000/bug-view-4.html,,4,售后服务页面问题,,,BUG,bug,resolved,resolved,,,2012-06-05T03:00:19.000+00:00,2022-10-05T04:10:08.000+00:00,,,,,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoStory:1:4,1,,,,0, -zentao:ZentaoBug:1:5,http://iwater.red:8000/bug-view-5.html,,5,首页页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:56:11.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:1,1,,,,0, -zentao:ZentaoBug:1:6,http://iwater.red:8000/bug-view-6.html,,6,新闻中心页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,,,zentao:ZentaoStory:1:2,2,,,,0,2022-10-05T16:00:00.000+00:00 +zentao:ZentaoBug:1:1,http://iwater.red:8000/bug-view-1.html,,1,首页页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:56:11.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:1,1,3,,,0, +zentao:ZentaoBug:1:2,http://iwater.red:8000/bug-view-2.html,,2,新闻中心页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,,,zentao:ZentaoStory:1:2,2,3,,,0,2022-10-05T16:00:00.000+00:00 +zentao:ZentaoBug:1:3,http://iwater.red:8000/bug-view-3.html,,3,成果展示页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:58:22.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:8,测试乙,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:3,1,3,,,0, +zentao:ZentaoBug:1:4,http://iwater.red:8000/bug-view-4.html,,4,售后服务页面问题,,,BUG,bug,resolved,resolved,,,2012-06-05T03:00:19.000+00:00,2022-10-05T04:10:08.000+00:00,,,,,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoStory:1:4,1,3,,,0, +zentao:ZentaoBug:1:5,http://iwater.red:8000/bug-view-5.html,,5,首页页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:56:11.000+00:00,2021-04-28T03:09:08.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,zentao:ZentaoAccount:1:4,开发甲,zentao:ZentaoStory:1:1,1,3,,,0, +zentao:ZentaoBug:1:6,http://iwater.red:8000/bug-view-6.html,,6,新闻中心页面问题,,,BUG,bug,DONE,active,,,2012-06-05T02:57:11.000+00:00,2022-10-05T04:19:22.000+00:00,,,,,zentao:ZentaoAccount:1:7,测试甲,,,zentao:ZentaoStory:1:2,2,3,,,0,2022-10-05T16:00:00.000+00:00 diff --git a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug_for_due_date.csv b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug_for_due_date.csv index 3192e753b47..e33e7b7a0d6 100644 --- a/backend/plugins/zentao/e2e/snapshot_tables/issues_bug_for_due_date.csv +++ b/backend/plugins/zentao/e2e/snapshot_tables/issues_bug_for_due_date.csv @@ -1,2 +1,2 @@ id,url,icon_url,issue_key,title,description,epic_key,type,original_type,status,original_status,story_point,resolution_date,created_date,updated_date,lead_time_minutes,original_estimate_minutes,time_spent_minutes,time_remaining_minutes,creator_id,creator_name,assignee_id,assignee_name,parent_issue_id,priority,severity,urgency,component,is_subtask,due_date -zentao:ZentaoBug:1:4,http://iwater.red:8000/bug-view-4.html,,4,售后服务页面问题,,,BUG,bug,resolved,resolved,,2022-10-05T04:09:59.000+00:00,2012-06-05T03:00:19.000+00:00,2022-10-05T04:10:08.000+00:00,5434629,,,,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoStory:1:4,1,,,,0,2022-10-05T04:09:59.000+00:00 +zentao:ZentaoBug:1:4,http://iwater.red:8000/bug-view-4.html,,4,售后服务页面问题,,,BUG,bug,resolved,resolved,,2022-10-05T04:09:59.000+00:00,2012-06-05T03:00:19.000+00:00,2022-10-05T04:10:08.000+00:00,5434629,,,,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoAccount:1:9,测试丙,zentao:ZentaoStory:1:4,1,3,,,0,2022-10-05T04:09:59.000+00:00 diff --git a/backend/plugins/zentao/tasks/bug_convertor.go b/backend/plugins/zentao/tasks/bug_convertor.go index a1af838ffe3..1d2f6ca7551 100644 --- a/backend/plugins/zentao/tasks/bug_convertor.go +++ b/backend/plugins/zentao/tasks/bug_convertor.go @@ -88,7 +88,7 @@ func ConvertBug(taskCtx plugin.SubTaskContext) errors.Error { Priority: getPriority(toolEntity.Pri), CreatorName: toolEntity.OpenedByName, AssigneeName: toolEntity.AssignedToName, - Severity: string(rune(toolEntity.Severity)), + Severity: getSeverity(toolEntity.Severity), Url: convertIssueURL(toolEntity.Url, "bug", toolEntity.ID), OriginalProject: getOriginalProject(data), Status: toolEntity.StdStatus, diff --git a/backend/plugins/zentao/tasks/shared.go b/backend/plugins/zentao/tasks/shared.go index 751093e7d6f..ad55219e9ea 100644 --- a/backend/plugins/zentao/tasks/shared.go +++ b/backend/plugins/zentao/tasks/shared.go @@ -24,6 +24,7 @@ import ( "path" "reflect" "regexp" + "strconv" "strings" "github.com/apache/devlake/core/dal" @@ -80,6 +81,11 @@ func getPriority(pri int) string { */ } +// getSeverity formats the numeric zentao bug severity (e.g. 3) as its decimal string ("3") +func getSeverity(severity int) string { + return strconv.Itoa(severity) +} + func getOriginalProject(data *ZentaoTaskData) string { if data.Options.ProjectId != 0 { return data.ProjectName diff --git a/backend/plugins/zentao/tasks/shared_test.go b/backend/plugins/zentao/tasks/shared_test.go index 3bec1ca23ef..d344759009e 100644 --- a/backend/plugins/zentao/tasks/shared_test.go +++ b/backend/plugins/zentao/tasks/shared_test.go @@ -195,3 +195,20 @@ func Test_getZentaoWebURL(t *testing.T) { }) } } + +func Test_getSeverity(t *testing.T) { + tests := []struct { + severity int + want string + }{ + {1, "1"}, + {3, "3"}, + {4, "4"}, + {10, "10"}, + } + for _, tt := range tests { + if got := getSeverity(tt.severity); got != tt.want { + t.Errorf("getSeverity(%d) = %q, want %q", tt.severity, got, tt.want) + } + } +}