Skip to content

fix: 修复sdk网关接口问题 --story=130003551#745

Merged
guohelu merged 2 commits into
TencentBlueKing:developfrom
guohelu:develop_0525
May 25, 2026
Merged

fix: 修复sdk网关接口问题 --story=130003551#745
guohelu merged 2 commits into
TencentBlueKing:developfrom
guohelu:develop_0525

Conversation

@guohelu

@guohelu guohelu commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Reviewed, transaction id: 80850

# Reviewed, transaction id: 80850

@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.

Review Summary

本 PR 修复了 SDK 网关接口相关问题,主要变更包括:

  1. 文档更新(sdk_create_mock_task)— 添加 pipeline_tree 参数说明,移除 pipeline_tree 版本说明
  2. 修正 api-resources.yml 中 plugin_service/logs 的网关路径
  3. 任务权限注入逻辑调整 — 移除 MOCK 限制并增加 FLOW_ 前缀区分模板权限
  4. 依赖升级 — 从本地 .whl 切换到正式发布版本

⚠️ 发现一个文档与代码不一致的问题,详见行内评论。其余变更逻辑清晰合理。

|------------------------|----------|----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name | string | 是 | 任务名 |
| creator | string | 是 | 创建者 |
| pipeline_tree | dict | 是 | 模板流程数据 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ 文档标注 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")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ 移除了 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

@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.

增量审查总结

新提交 (9fa5cbe) 修复了测试失败问题,补充了测试数据中缺失的 template_id 字段并更新了断言以匹配新的 FLOW_ 前缀逻辑,变更合理。

之前评论状态:

  • ⚠️ pipeline_tree 文档与代码不一致:经核实,sdk_create_mock_task 网关资源的 backend path 路由到 TemplateViewSet.create_mock_task,该视图使用 CreateMockTaskWithPipelineTreeSerializerpipeline_tree 确实是必填参数。✅ 文档修改正确,无问题。
  • ⚠️ template_id 判空问题:仍未修复。Task 模型中 template_idnull=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")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ 此前报告的 template_id 判空问题仍存在。Task 模型中 template_id = BigIntegerField(null=True),对于非模板创建的任务此值可能为 None,会产生无效查询。建议:if task_detail.get("template_id"): base_query |= Q(...)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.87%. Comparing base (ea70462) to head (9fa5cbe).
⚠️ Report is 28 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@guohelu guohelu merged commit 2987ad1 into TencentBlueKing:develop May 25, 2026
7 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.

2 participants