fix: 修复sdk网关接口问题 --story=130003551#745
Conversation
# Reviewed, transaction id: 80850
There was a problem hiding this comment.
Review Summary
本 PR 修复了 SDK 网关接口相关问题,主要变更包括:
- 文档更新(sdk_create_mock_task)— 添加 pipeline_tree 参数说明,移除 pipeline_tree 版本说明
- 修正 api-resources.yml 中 plugin_service/logs 的网关路径
- 任务权限注入逻辑调整 — 移除 MOCK 限制并增加 FLOW_ 前缀区分模板权限
- 依赖升级 — 从本地 .whl 切换到正式发布版本
| |------------------------|----------|----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| | name | string | 是 | 任务名 | | ||
| | creator | string | 是 | 创建者 | | ||
| | pipeline_tree | dict | 是 | 模板流程数据 | |
There was a problem hiding this comment.
pipeline_tree 为必选参数(必选: 是),但实际代码中 CreateMockTaskWithTemplateIdSerializer 并没有此字段,pipeline_tree 是由后端根据 template_id 自动获取的(优先草稿版本)。此处文档与代码实现不一致,建议移除该字段或标注为「由系统自动填充,无需传入」。
| # 只有当任务是MOCK调试任务时,可以TEMPLATE的MOCK权限条件 | ||
| if task_detail.get("create_method") == "MOCK": | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") |
There was a problem hiding this comment.
create_method == "MOCK" 的条件判断后,所有任务都会查询 TEMPLATE 权限。但 Task 模型中 template_id 允许为 null(null=True, blank=True),对于没有关联模板的任务,task_detail["template_id"] 可能为 None,会产生 Q(resource_id=None, resource_type="TEMPLATE") 的无效查询。建议加判空保护:if task_detail.get("template_id"): base_query |= ...
# Reviewed, transaction id: 80853
There was a problem hiding this comment.
增量审查总结
新提交 (9fa5cbe) 修复了测试失败问题,补充了测试数据中缺失的 template_id 字段并更新了断言以匹配新的 FLOW_ 前缀逻辑,变更合理。
之前评论状态:
⚠️ pipeline_tree文档与代码不一致:经核实,sdk_create_mock_task网关资源的 backend path 路由到TemplateViewSet.create_mock_task,该视图使用CreateMockTaskWithPipelineTreeSerializer,pipeline_tree确实是必填参数。✅ 文档修改正确,无问题。⚠️ template_id判空问题:仍未修复。Task 模型中template_id为null=True,非 MOCK 创建的任务可能没有关联模板,task_detail["template_id"]可能为 None,建议加判空保护。
| # 只有当任务是MOCK调试任务时,可以TEMPLATE的MOCK权限条件 | ||
| if task_detail.get("create_method") == "MOCK": | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") |
There was a problem hiding this comment.
template_id 判空问题仍存在。Task 模型中 template_id = BigIntegerField(null=True),对于非模板创建的任务此值可能为 None,会产生无效查询。建议:if task_detail.get("template_id"): base_query |= Q(...)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #745 +/- ##
===========================================
+ Coverage 82.14% 82.87% +0.72%
===========================================
Files 296 296
Lines 17925 17967 +42
===========================================
+ Hits 14725 14890 +165
+ Misses 3200 3077 -123 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Reviewed, transaction id: 80850