Skip to content

fix: The input content of the knowledge base write node is empty, but the workflow can be published#4453

Merged
zhanweizhang7 merged 1 commit intov2from
pr@v2@fix_knowledge_write_node
Dec 8, 2025
Merged

fix: The input content of the knowledge base write node is empty, but the workflow can be published#4453
zhanweizhang7 merged 1 commit intov2from
pr@v2@fix_knowledge_write_node

Conversation

@shaohuzhang1
Copy link
Copy Markdown
Contributor

fix: The input content of the knowledge base write node is empty, but the workflow can be published

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Dec 8, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Dec 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

})
</script>

<style lang="scss" scoped></style>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There are a few improvements that can be made to enhance the code:

  1. Remove Redundant Code: The set function call in the computed property can be simplified using direct assignment.

  2. Optimize Event Handling: Ensure all event handlers are properly bound and optimized, especially on component initialization.

  3. Code Readability: Add comments where needed for better understanding of the logic flow.

Here's the updated version with these improvements:

<!-- Updated Form Template -->
<el-form
  label-position="top"
  require-asterisk-position="right"
  label-width="auto"
  ref="IntentClassifyNodeFormRef"
  hide-required-asterisk
>
  <!-- Input Content Field -->
  <el-form-item
    prop="document_list"
    :label="$t('common.inputContent')"
    :rules="{
      message: $t('workflow.nodes.textToSpeechNode.content.label'),
      trigger: 'change',
      required: true,
    }"
  >
    <template #label>
      <div class="flex-between">
        <div>
          {{ $t('common.inputContent') }}
          <span class="color-danger">*</span>
        </div>
      </div>
    </template>
    <NodeCascader
      ref="nodeCascaderRef"
      :nodeModel="nodeModel"
      class="w-full"
      :placeholder="$t('workflow.nodes.textToSpeechNode.content.label')"
      v-model="form_data.document_list"
    />
  </el-form-item>
</el-form>

Updated Script Setup

<script setup lang="ts">
import NodeContainer from '@/workflow/common/NodeContainer.vue';
import { computed, onMounted, ref } from 'vue';
import { set } from 'lodash';
import NodeCascader from '@/workflow/common/NodeCascader.vue';
import { isLastNode } from '@/workflow/common/data';

const props = defineProps<{ nodeModel: any }>();
// Remove redundant usage of set in form_data computed property
const form_data = computed({
  get: () => {
    return props.nodeModel.properties.node_data || {};
  },
  // Simplified setter
  set(value) {
    set(props.nodeModel.properties, 'node_data', value);
  },
});

+// Function to handle validation
async function validate() {
  let ps = [
    KnowledgeWriteRef.value?.validate(),
    nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(''),
  ];
  try {
    await Promise.all(ps);
    return null; // Return success after successful validation
  } catch (err) {
    throw new Error({ node: props.nodeModel, errMessage: err });
  }
}

/* Initialization Logic */
onMounted(() => {
  if (!props.nodeModel.properties.node_data.is_result) {
    if (isLastNode(props.nodeModel)) {
      props.nodeModel.properties.node_data.is_result = true;
    }
  }
  // Bind custom validate function to props.nodeModel properties
  set(props.nodeModel, 'validate', validate);
});
</script>

<style lang="scss" scoped></style>

Summary

  • Removed redundancy with setting form data directly.
  • Enhanced readability by adding comments.
  • Added validation logic as a separate function for reusability and clarity.
  • Ensured proper initialization and error handling.

These changes should make the code cleaner, more maintainable, and easier to understand.

@zhanweizhang7 zhanweizhang7 merged commit bd43d2f into v2 Dec 8, 2025
3 of 6 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_knowledge_write_node branch December 8, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants