Fix missing flowData for CustomTemplate Tool during import#5542
Conversation
Summary of ChangesHello @chungyau97, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where custom template tools might lack essential flow data when imported into the system. By programmatically populating this data during the import process, it ensures the integrity and functionality of these tools, improving overall system robustness and backward compatibility for existing exports. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with missing flowData for CustomTemplate of type Tool during the import process. The fix correctly reconstructs the flowData from other properties on the imported object. However, the condition used to identify the relevant items is a bit fragile and could lead to errors in the future if the Tool entity is modified. I've added a review comment with a suggestion to make the check more robust and prevent potential bugs.
| function insertWorkspaceId(importedData: any, activeWorkspaceId?: string) { | ||
| if (!activeWorkspaceId) return importedData | ||
| importedData.forEach((item: any) => { | ||
| if (item.type === 'Tool') { |
There was a problem hiding this comment.
The condition item.type === 'Tool' is a bit fragile. While it currently works because Tool entities don't have a type property, this could change in the future. If a Tool object ever gets a type: 'Tool' property, this code would add a flowData property to it. Since the Tool entity doesn't have a flowData column, this would cause a database error upon saving.
A more robust check would be to also verify that the item is a CustomTemplate. A simple way to do this is to check for a property that exists on CustomTemplate but not on Tool, like badge.
| if (item.type === 'Tool') { | |
| if (item.type === 'Tool' && 'badge' in item) { |
…#5542) fix(services/export-import): import missing flowData for Custom Template Tool
Description
Fix null value in column "flowData" of relation "custom_template" violates not-null constraint.
Result
Enterprise
Cloud