Skip to content

feat: 支持HTTP回调 --story=132632590#681

Open
Mianhuatang8 wants to merge 3 commits intoTencentBlueKing:developfrom
Mianhuatang8:dev_new_http
Open

feat: 支持HTTP回调 --story=132632590#681
Mianhuatang8 wants to merge 3 commits intoTencentBlueKing:developfrom
Mianhuatang8:dev_new_http

Conversation

@Mianhuatang8
Copy link
Copy Markdown
Collaborator

Reviewed, transaction id: 78200

# Reviewed, transaction id: 78200
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code Review Summary

本 PR 实现了 HTTP 回调功能,整体结构清晰,前端组件拆分合理。以下是审查发现的几个问题:

🚨 Critical

  • formData.labels 属性已重命名为 template_labels,但 editLabelConfirm 中仍引用旧名,会导致运行时错误

⚠️ Important

  • beforeClose() 的脏数据检测未包含 webhook_configs / enable_webhook,会导致误弹"未保存"提示
  • debugMock() 缺少 try/catch,网络异常时会产生 unhandled promise rejection
  • Headers 表格中 "操作" 和 "删除" 为硬编码中文,未使用 $t() 国际化

✨ Minor

  • enable_webhook|| false 缺少空格(代码风格)

总体来说,核心功能实现完整,修复上述问题后即可合入。

if (resp.result) {
this.$emit('updateTemplateLabelList');
this.labelDialogShow = false;
this.formData.labels.push(resp.data.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.

🚨 formData.labelsdata() 中已重命名为 template_labels,但此处仍引用旧名 labels。会导致运行时 TypeError: Cannot read properties of undefined (reading 'push'),需改为 this.formData.template_labels.push(resp.data.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.

✅ 此问题仍存在于最新提交中(第 646 行)。formData.labels 仍引用旧属性名,应为 this.formData.template_labels。此外,saveTemplateData 现在期望 template_labels 是对象数组(通过 .map(label => label.id) 提取 ID),但这里 push 的是 resp.data.id(纯 ID),应改为 push 整个 resp.data 对象。

Comment thread frontend/src/views/template/TemplateEdit/TemplateSetting/HttpCallbackConfig.vue Outdated
Comment thread frontend/src/views/template/TemplateEdit/TemplateSetting/HttpCallbackConfig.vue Outdated
Comment thread frontend/src/store/modules/template.js Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@8f93442). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #681   +/-   ##
==========================================
  Coverage           ?   81.29%           
==========================================
  Files              ?      280           
  Lines              ?    16632           
  Branches           ?        0           
==========================================
  Hits               ?    13521           
  Misses             ?     3111           
  Partials           ?        0           

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

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Incremental Code Review Summary

最新提交 552232d 修复了缩进问题,并处理了部分之前审查中的反馈。

✅ 已解决的问题

  • beforeClose() 脏数据检测现已包含 webhook_configsenable_webhook
  • Headers 表格中 操作 / 删除 已使用 $t() 国际化
  • enable_webhook || false 空格已补齐

🚨 仍需修复

  • formData.labels 引用错误(TabTemplateConfig.vue:646):editLabelConfirm 中仍引用 this.formData.labels,但 data() 中该属性已重命名为 template_labels。此外 saveTemplateData 现在期望 template_labels 为对象数组,应 push resp.data 而非 resp.data.id

⚠️ 仍需修复

  • debugMock() 缺少错误处理(HttpCallbackConfig.vue:582):async debugMock() 未包裹 try/catch,网络异常时会产生 unhandled promise rejection

# Reviewed, transaction id: 78411
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Incremental Code Review Summary

最新提交 4030f35 为调试按钮添加了 loading 状态,并用 try/finally 包裹了 debugMock 逻辑,是合理的改进。

✅ 已解决的问题

  • beforeClose() 脏数据检测已包含 webhook_configsenable_webhook
  • Headers 表格中 操作 / 删除 已使用 $t() 国际化
  • enable_webhook || false 空格已修复
  • debugMock() 已添加 try/finally 确保 loading 状态复位

🚨 仍未解决

  • editLabelConfirmthis.formData.labels.push(...) 仍引用不存在的属性(已在之前审查中报告两次,第 646 行)

⚠️ 新发现

  • getTemplateConfig() 直接对 formData.webhookConfigs 执行 parseInt.filter(),会原地修改表单数据,多次调用可能导致非预期副作用
  • debugMock()try/finally 但无 catch,请求失败时用户看不到错误提示

triggers,
webhook_configs: webhookConfigs,
enable_webhook: this.enableWebhook,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ getTemplateConfig() 直接对 this.formData.webhookConfigs.extra_info 执行 parseInt().filter(),会原地修改 formData 的数据。如果此方法被多次调用(如 beforeCloseonSaveConfig 中),headers 会被重复过滤,数值字段也会被反复 parseInt。建议先 tools.deepClone(webhookConfigs) 再做转换,或在提交时一次性转换。

theme: 'success',
});
}
} finally {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ try/finally 确保了 isDebugging 复位,但缺少 catch 块——当 debugWebhook 请求失败(网络异常、后端 500)时,用户不会看到任何错误提示。建议增加 catch(e) 并通过 $bkNotify$bkMessage 展示失败信息。

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.

3 participants