fix: 修改字画布节点输出不正确问题 --story=135517916 - #841
Conversation
There was a problem hiding this comment.
Code Review Summary
本次 PR 修复了子画布节点循环输出中的重复记录问题,逻辑清晰:通过 inner_loop 去重后再追加本次输出。主要关注点如下:
🚨 需要关注
-
TaskInstance.objects.get(id=parent_task_id)缺少异常处理(line 803):若parent_task_id为None或记录不存在,将抛出未捕获异常。此时finish_schedule()已在 line 790 调用,节点会进入不一致状态(schedule 结束但输出未设置)。 -
finish_schedule()与新逻辑的执行顺序(line 790 vs 802-822):新增的 DB 查询和 runtime 调用位于finish_schedule()之后,若这些操作失败,schedule 已标记完成但输出不完整。建议将finish_schedule()移到所有输出设置逻辑之后,或对新增逻辑加 try/except 保护。
⚠️ 建议
- 新增的 runtime 操作缺少日志:
get_context_values和update_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 |
There was a problem hiding this comment.
🚨 此处 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() |
There was a problem hiding this comment.
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}) |
There was a problem hiding this comment.
✨ 建议在 get_context_values 和 update_context_values 前后添加 debug 日志(如 self.logger.info(f"dedup loop outputs for inner_loop={self.inner_loop}, removed {len(current_value) - len(filtered_value)} items")),便于排查循环输出异常。
No description provided.