feat: 增加节点循环执行机制 --story=130003551#585
Open
guohelu wants to merge 1 commit intoTencentBlueKing:feat/template_loopfrom
Open
feat: 增加节点循环执行机制 --story=130003551#585guohelu wants to merge 1 commit intoTencentBlueKing:feat/template_loopfrom
guohelu wants to merge 1 commit intoTencentBlueKing:feat/template_loopfrom
Conversation
# Reviewed, transaction id: 71717
|
v_ghluguo seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
🔍 代码审查总结
本 PR 实现了节点循环执行机制。审查发现以下关键问题需要处理:
🚨 严重问题
- 索引越界风险:loop.py:39 在分割字符串时未做边界检查,可能导致 IndexError
- 除零风险:validator.py:51 在空列表上调用 min() 会抛出 ValueError
⚠️ 逻辑问题
- 异常处理宽泛:decorators.py:48 捕获所有异常但仅记录日志,可能掩盖严重错误
- 状态判断逻辑:operations.py:496 的状态判断仅检查 _result 字段,可能不够健壮
✨ 建议
- 建议添加单元测试覆盖边界情况(空列表、索引越界等)
- 考虑为新增的 loop_config 字段添加 schema 验证
审查了 8 个变更文件,标注了 4 个高优先级问题
| def get_value(self): | ||
| # 循环节点因引用 | ||
| if hasattr(self, "inner_loop") and self.inner_loop != -1: | ||
| return self.value.split(",")[self.inner_loop - 1] |
There was a problem hiding this comment.
🚨 索引越界风险:当 inner_loop 超过数组长度时会抛出 IndexError。建议添加边界检查:
values = self.value.split(",")
if self.inner_loop > len(values):
raise ValueError(f"inner_loop {self.inner_loop} exceeds values length {len(values)}")
return values[self.inner_loop - 1]| if not loop_config.get("enable", False): | ||
| continue | ||
| loop_params = loop_config.get("loop_params", []) | ||
| if loop_config["loop_times"] != min([len(param.split(",")) for key, param in loop_params.items()]): |
There was a problem hiding this comment.
🚨 空列表异常:当 loop_params 为空字典时,min() 会抛出 ValueError。建议先检查是否为空:
if not loop_params:
raise exceptions.ParserWebTreeException("loop_params is empty")
lengths = [len(param.split(",")) for key, param in loop_params.items()]
if loop_config["loop_times"] != min(lengths):
raise exceptions.ParserWebTreeException("loop times not matched")|
|
||
| # 重试记录必然是因为失败才重试,设置了循环策略的节点只有成功才能接着循环 | ||
| if node_info.loop_strategy: | ||
| if hist["skip"] or hist["outputs"].get("_result"): |
There was a problem hiding this comment.
if hist["skip"] or (hist["outputs"].get("_result") is True):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reviewed, transaction id: 71717