Skip to content

fix: return CurrentStepAssigneeUser by username#3147

Merged
BugsGuru merged 1 commit intomainfrom
fix_workflow_name
Sep 29, 2025
Merged

fix: return CurrentStepAssigneeUser by username#3147
BugsGuru merged 1 commit intomainfrom
fix_workflow_name

Conversation

@Jarvis1105
Copy link
Copy Markdown
Contributor

@Jarvis1105 Jarvis1105 commented Sep 29, 2025

User description

关联的 issue

#3133

描述你的变更

  • CurrentStepAssigneeUser返回用户名

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 使用 dms.GetUserNameWithDelTag 转换用户ID

  • 过滤空字符串防止处理异常

  • 修改返回值为用户名列表


Diagram Walkthrough

flowchart LR
  A["处理 CurrentStepAssigneeUserIds 字符串"] -- "调用转换函数" --> B["dms.GetUserNameWithDelTag"]
  B -- "生成用户名列表" --> C["更新 CurrentStepAssigneeUser 字段"]
Loading

File Walkthrough

Relevant files
Bug fix
workflow.go
使用用户名替换用户ID                                                                                           

sqle/api/controller/v1/workflow.go

  • 新增变量 CurrentStepAssigneeUserNames 存储转换结果
  • 使用 strings.Split 分割字符串并过滤空值
  • 替换 WorkflowDetailResV1 中的 CurrentStepAssigneeUser 字段值
+9/-1     

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
添加有效性检查


建议在拆分并处理workflow.CurrentStepAssigneeUserIds.String前,先判断该字段是否有效(例如检查Valid属性),以避免因空值或无效数据造成程序panic。添加有效性检查可以防止因非法或未初始化数据引起的不安全操作。

sqle/api/controller/v1/workflow.go [838-844]

 CurrentStepAssigneeUserNames := make([]string, 0)
-    for _, currentStepAssigneeUser := range strings.Split(workflow.CurrentStepAssigneeUserIds.String, ",") {
-        if currentStepAssigneeUser == "" {
-            continue
+    if workflow.CurrentStepAssigneeUserIds.Valid {
+        for _, currentStepAssigneeUser := range strings.Split(workflow.CurrentStepAssigneeUserIds.String, ",") {
+            if currentStepAssigneeUser == "" {
+                continue
+            }
+            CurrentStepAssigneeUserNames = append(CurrentStepAssigneeUserNames, dms.GetUserNameWithDelTag(currentStepAssigneeUser))
         }
-        CurrentStepAssigneeUserNames = append(CurrentStepAssigneeUserNames, dms.GetUserNameWithDelTag(currentStepAssigneeUser))
     }
Suggestion importance[1-10]: 8

__

Why: The suggestion improves error handling by checking workflow.CurrentStepAssigneeUserIds.Valid before processing, which can prevent unexpected panics; the improved code reflects this additional safety check accurately.

Medium

@BugsGuru BugsGuru merged commit f677fd6 into main Sep 29, 2025
4 checks passed
@BugsGuru BugsGuru deleted the fix_workflow_name branch September 29, 2025 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants