Fix external calls to the published workflow version update#783
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces logic to synchronize external call configurations when a robot is published or a version is enabled, ensuring that the active version is correctly reflected in the external call settings. Feedback includes addressing potential data corruption from double-serializing parameters, fixing the placement of the synchronization call in the publishing flow to cover all scenarios, and reducing code duplication by extracting shared logic. Additionally, there are suggestions to correct indentation and remove trailing semicolons to maintain project style consistency.
| project_id: props.robotId, | ||
| version: lastPublishData.version, | ||
| status: 1, | ||
| parameters: JSON.stringify(currentConfig.parameters), |
There was a problem hiding this comment.
Using JSON.stringify(currentConfig.parameters) may lead to double-serialization if currentConfig.parameters is already a string. It is safer to verify the type before stringifying to avoid corrupted data in the database.
parameters: typeof currentConfig.parameters === 'string' ? currentConfig.parameters : JSON.stringify(currentConfig.parameters),
| if (Number(basicFormData.value.version) > 1 && res.data === 'market') { | ||
| message.success(t('publish.syncMarketSuccess')) | ||
| // 更新已发布工作流外部调用版本 | ||
| refreshExternalCall() |
There was a problem hiding this comment.
The refreshExternalCall() function is currently only called within one specific branch of the applicationReleaseCheck callback. This means the external call configuration won't be updated if a market release application is triggered (the first callback at line 82). Since refreshExternalCall already checks enableLastVersion.value, it should be called directly after publishRobot succeeds to ensure the version is synchronized whenever it is enabled.
| const refreshExternalCall = async () => { | ||
| try { | ||
| // 获取工作流外部调用版本外部调用配置 | ||
| const currentConfig = await getRobotLastIsExternalCall(props.robotId) | ||
|
|
||
| // 是否开启外部调用且启用当前发布版本 | ||
| if (currentConfig?.status === 1 && enableLastVersion.value) { | ||
| console.log('检测到外部调用已开启,执行强制更新以同步版本...') | ||
|
|
||
| const updatePayload = { | ||
| ...currentConfig, | ||
| project_id: props.robotId, | ||
| version: lastPublishData.version, | ||
| status: 1, | ||
| parameters: JSON.stringify(currentConfig.parameters), | ||
| } | ||
|
|
||
| // 更新已发布工作流 | ||
| await setRobotIsExternalCall(updatePayload) | ||
| console.log('外部调用配置强制更新成功') | ||
| } | ||
| } catch (error) { | ||
| console.error('发版后更新已发布工作流外部调用版本失败', error) | ||
| } | ||
| } |
There was a problem hiding this comment.
| // 更新已发布工作流外部调用版本 | ||
| const refreshExternalCall = async (item: versionMap) => { | ||
| try { | ||
| // 获取工作流外部调用版本外部调用配置 | ||
| const currentConfig = await getRobotLastIsExternalCall(props.robotId) | ||
|
|
||
| // 是否开启外部调用 | ||
| if (currentConfig?.status === 1) { | ||
| console.log('检测到外部调用已开启,更新外部调用版本...') | ||
|
|
||
| const updatePayload = { | ||
| ...currentConfig, | ||
| project_id: props.robotId, | ||
| version: item.versionNum, | ||
| status: 1, | ||
| parameters: JSON.stringify(currentConfig.parameters), | ||
| } | ||
|
|
||
| // 更新已发布工作流 | ||
| await setRobotIsExternalCall(updatePayload) | ||
| console.log('外部调用配置强制更新成功') | ||
| } | ||
| } catch (error) { | ||
| console.error('发版后更新已发布工作流外部调用版本失败', error) | ||
| } | ||
| } |
Signed-off-by: tf1928 <codertf@163.com>
97de118 to
513055d
Compare
📝 Pull Request 描述 | Description
Fixed an issue where, when updating, rolling back, or enabling versions of published applications under the designer, the corresponding externally callable applications under the executor were not updated synchronously.
🎯 变更类型 | Change Type
🔗 相关 Issue | Related Issues
📋 变更内容 | Changes Made
主要变更 | Main Changes
技术细节 | Technical Details
🧪 测试 | Testing
测试环境 | Test Environment
测试步骤 | Test Steps
2. The error message has been modified for concurrent version v2. The debugger and executor have been updated, but the external API call is still using version v1, and the corresponding data item in the database has not been updated.
3. After fixing the code, the prompt content was modified for concurrent version v3, and the debugging, executor, external API, and database were all successfully updated.
4. In the Designer - Version Management section, different versions were rolled back and enabled. The debugger, executor, external API, and database were all successfully updated, and the repair was completed.
测试结果 | Test Results
📸 截图/录屏 | Screenshots/Recordings
变更前 | Before
变更后 | After
破坏性变更详情 | Breaking Changes Details
✅ 检查清单 | Checklist
代码质量 | Code Quality
测试 | Testing
文档 | Documentation
其他 | Others
📌 额外说明 | Additional Notes
🙏 致谢 | Acknowledgements
📖 提示 | Tips:
/cc @maintainers
测试结果 | Test Results
📸 截图/录屏 | Screenshots/Recordings
变更前 | Before
变更后 | After
破坏性变更详情 | Breaking Changes Details
✅ 检查清单 | Checklist
代码质量 | Code Quality
测试 | Testing
文档 | Documentation
其他 | Others
📌 额外说明 | Additional Notes
🙏 致谢 | Acknowledgements
📖 提示 | Tips:
/cc @maintainers