Skip to content

fix: 修改字画布节点输出不正确问题 --story=135517916 - #841

Merged
guohelu merged 1 commit into
TencentBlueKing:develop_subcanvasfrom
guohelu:develop_subcanvas_0729
Jul 30, 2026
Merged

fix: 修改字画布节点输出不正确问题 --story=135517916#841
guohelu merged 1 commit into
TencentBlueKing:develop_subcanvasfrom
guohelu:develop_subcanvas_0729

Conversation

@guohelu

@guohelu guohelu commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

本次 PR 修复了子画布节点循环输出中的重复记录问题,逻辑清晰:通过 inner_loop 去重后再追加本次输出。主要关注点如下:

🚨 需要关注

  1. TaskInstance.objects.get(id=parent_task_id) 缺少异常处理(line 803):若 parent_task_idNone 或记录不存在,将抛出未捕获异常。此时 finish_schedule() 已在 line 790 调用,节点会进入不一致状态(schedule 结束但输出未设置)。

  2. finish_schedule() 与新逻辑的执行顺序(line 790 vs 802-822):新增的 DB 查询和 runtime 调用位于 finish_schedule() 之后,若这些操作失败,schedule 已标记完成但输出不完整。建议将 finish_schedule() 移到所有输出设置逻辑之后,或对新增逻辑加 try/except 保护。

⚠️ 建议

  1. 新增的 runtime 操作缺少日志get_context_valuesupdate_context_values 是关键步骤,建议添加日志以便排查循环输出异常问题。

整体逻辑正确,修复方向合理,处理上述异常安全性问题后即可合入。

# 避免同一次循环被重复回调时(如节点先失败跳过、后重试成功的场景)
# 导致上下文输出列表中出现重复记录。之后再由 extract_outputs 统一追加本次的 outputs。
parent_task_id = parent_data.get_one_of_inputs("task_id")
parent_pipeline_id = TaskInstance.objects.get(id=parent_task_id).instance_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 此处 TaskInstance.objects.get(id=parent_task_id) 缺少异常保护。若 parent_task_id 无效或记录不存在,异常会在 finish_schedule() 之后抛出,导致节点状态不一致。建议参照上方 line 773-779 的模式加 try/except 处理。


node = self.runtime.get_node(self.id)
loop_outputs_key = node.loop_outputs_key
self.finish_schedule()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ finish_schedule() 在新增的 DB 查询和 update_context_values 之前调用。若下方逻辑异常,节点 schedule 已结束但输出未正确设置。建议将 finish_schedule() 移到 else 分支末尾(line 835 之后),或用 try/except 包裹新增逻辑以确保输出兜底。

parent_task_id = parent_data.get_one_of_inputs("task_id")
parent_pipeline_id = TaskInstance.objects.get(id=parent_task_id).instance_id

loop_context_values = self.runtime.get_context_values(parent_pipeline_id, {loop_outputs_key})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ 建议在 get_context_valuesupdate_context_values 前后添加 debug 日志(如 self.logger.info(f"dedup loop outputs for inner_loop={self.inner_loop}, removed {len(current_value) - len(filtered_value)} items")),便于排查循环输出异常。

@guohelu
guohelu merged commit 7efb2ec into TencentBlueKing:develop_subcanvas Jul 30, 2026
5 checks passed
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.

1 participant