Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@BugsGuru
Copy link
Collaborator

@BugsGuru BugsGuru commented Jan 9, 2026

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/2623

描述你的变更

工单webhook通知时,区分通过cloudbeaver工作台非DQL自动创建工单的情况

确认项(pr提交后操作)

Tip

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


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


Description

  • 新增针对自动创建工单的执行函数

  • 扩展工单通知类型为 auto_exec_success/auto_exec_failed

  • 修改 ExecuteWorkflow/ExecuteTasksProcess 增加 isAutoCreated 参数

  • 更新注释说明及调用逻辑区分自动和普通工单


Diagram Walkthrough

flowchart LR
  A["\"AutoCreateAndExecuteWorkflowV1\""] --> B["\"调用 executeWorkflowForAuto\""]
  B --> C["\"新增 isAutoCreated 参数传递\""]
  C --> D["\"ExecuteWorkflow 调整通知类型\""]
  D --> E["\"ExecuteTasksProcess 扩展自动执行逻辑\""]
  B --> F["\"更新通知类型逻辑\""]
Loading

File Walkthrough

Relevant files
Enhancement
workflow.go
调整工单执行函数支持自动创建逻辑                                                                                 

sqle/api/controller/v1/workflow.go

  • 替换 executeWorkflow 为 executeWorkflowForAuto
  • 新增执行自动创建工单的函数及详细注释
  • 修改 ExecuteTasksProcess 调用逻辑传递 isAutoCreated
+11/-4   
notification.go
扩展工单消息通知支持自动执行类型                                                                                 

sqle/notification/notification.go

  • 新增 WorkflowNotifyTypeAutoExecuteSuccess/Fail 类型
  • 扩展 getWorkflowNotifyTypeAction 分支处理
  • 修改 NotificationSubject 与 buildNotifyBody 中的通知逻辑
+10/-4   
workflow_schedule.go
扩展任务执行流程区分自动与普通工单                                                                               

sqle/server/workflow_schedule.go

  • 修改 ExecuteWorkflow 添加 isAutoCreated 参数判断
  • 根据参数调整通知调用(自动/普通)
  • 更新 ExecuteTasksProcess 注释及参数透传逻辑
+52/-5   

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

PR Reviewer Guide 🔍

(Review updated until commit df22a03)

🎫 Ticket compliance analysis ✅

2623 - PR Code Verified

Compliant requirements:

  • 自动工单的执行函数和通知类型已有扩展
  • isAutoCreated 参数在相关函数中已实现传递与逻辑分支

Requires further human verification:

  • 集成测试自动与普通工单的通知流程,确保前后端使用一致
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

逻辑一致性

请检查新添加的 executeWorkflowForAuto 函数与原有普通工单执行逻辑是否完全保持一致,特别是错误处理和通知调用的分支逻辑。

// executeWorkflowForAuto 执行自动创建的工单
// 此函数专门用于自动创建工单的执行流程,与普通工单执行的区别在于:
//   - 使用特殊的通知类型(auto_exec_success/auto_exec_failed)来区分自动创建和普通创建的工单
//   - 通过传递 isAutoCreated=true 给 ExecuteTasksProcess,确保 webhook 通知中的 action 字段为 "auto_exec_success" 或 "auto_exec_failed"
// 使用场景:
//   - AutoCreateAndExecuteWorkflowV1: 通过工作台执行非DQL类型SQL时自动创建的工单
// 注意: 此函数不应用于普通工单的执行,普通工单应使用其他执行流程
func executeWorkflowForAuto(projectUid string, workflow *model.Workflow, user *model.User) (string, error) {
	needExecTaskIds, err := GetNeedExecTaskIds(workflow, user)
	if err != nil {
		return "", err
	}
参数传递

请确认在 ExecuteWorkflow 与 ExecuteTasksProcess 中对 isAutoCreated 参数处理的逻辑,在未传递时默认为 false,并在传递 true 时正确切换为自动工单的通知类型。

// 判断是否为自动创建的工单
// 逻辑说明:
//   - 如果 isAutoCreated 参数未传递(len == 0),则 isAuto = false,使用普通工单通知类型
//   - 如果 isAutoCreated[0] == true,则 isAuto = true,使用自动创建工单的特殊通知类型
//   - 如果 isAutoCreated[0] == false,则 isAuto = false,使用普通工单通知类型
// 通知类型说明:
//   - 自动创建工单成功: WorkflowNotifyTypeAutoExecuteSuccess -> action: "auto_exec_success"
//   - 自动创建工单失败: WorkflowNotifyTypeAutoExecuteFail -> action: "auto_exec_failed"
//   - 普通工单成功: WorkflowNotifyTypeExecuteSuccess -> action: "exec_success"
//   - 普通工单失败: WorkflowNotifyTypeExecuteFail -> action: "exec_failed"
isAuto := len(isAutoCreated) > 0 && isAutoCreated[0]
if err != nil || task.Status == model.TaskStatusExecuteFailed {
	if isAuto {
		go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeAutoExecuteFail)
	} else {
		go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteFail)
	}
} else {
	if isAuto {
		go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeAutoExecuteSuccess)
	} else {
		go notification.NotifyWorkflow(string(workflow.ProjectId), workflow.WorkflowId, notification.WorkflowNotifyTypeExecuteSuccess)
	}

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@BugsGuru BugsGuru force-pushed the fix-auto-exec-webhook branch from a9347aa to f0c4ff5 Compare January 9, 2026 03:01
@github-actions
Copy link

github-actions bot commented Jan 9, 2026

Persistent review updated to latest commit f0c4ff5

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

Persistent review updated to latest commit df22a03

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

PR Code Suggestions ✨

No code suggestions found for the PR.

@Jarvis1105 Jarvis1105 merged commit 29d30ef into main Jan 9, 2026
4 checks passed
@Jarvis1105 Jarvis1105 deleted the fix-auto-exec-webhook branch January 9, 2026 03:21
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.

3 participants