Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Fix variable-assign-node cannot publish --bug=1052464 --user=刘瑞斌 【应用】-编排应用中存在变量赋值节点,发布应用失败 https://www.tapd.cn/57709429/s/1659401

--bug=1052464 --user=刘瑞斌 【应用】-编排应用中存在变量赋值节点,发布应用失败 https://www.tapd.cn/57709429/s/1659401
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 26, 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/test-infra repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 26, 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

return Promise.all(ps).catch((err: any) => {
return Promise.reject({ node: props.nodeModel, errMessage: err })
})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code is mostly correct, but there's an issue with the structure of the nodeCascaderRef2 mapping function when it might be undefined. It uses ...[] which can lead to unexpected behavior due to type widening if nodeCascaderRef2.value is not defined.

Here are some recommendations:

  1. Check for Undefined Value: Before attempting to map on nodeCascaderRef2, ensure that it exists. This prevents errors from occurring when calling .map() on an undefined value.

  2. Optimization: The current implementation will execute validate() calls serially instead of parallel for both replyNodeFormRef and each option in nodeCascaderRef. If you want to execute them in series, keep the existing Promise.all([...]).catch(). However, this ensures they are executed one after another without changing their order.

  3. Example Code:

const validate = async () => {
  let errorCount = 0;

  const allValidationsPromises = [
    replyNodeFormRef.value?.validate().then(() => {
      // Count validation success for replyNodeFormRef
      errorCount++;
    }).catch(err => {
      console.error('Validation failed:', err);
      errorCount++;
    }),

    ...nodeCascaderRef.value?.map(item => item.validate()).map(validateResult => {
      if (!validateResult.validated) { // Assuming each cascader node has a validated property indicating successful validation
        // Mark error for cascader nodes
        errorCount++;
      }
      return validateResult;
    }) || []

  ];

  await Promise.all(allValidationsPromises);

  if (errorCount === 0) {
    logger.info(`All validations passed.`);
  } else {
    throw new Error(`Failed to verify the form details: ${errorCount} errors found.`);
  }
};
  1. Error Handling: Ensure proper handling within catch() blocks. In the example above, if there are no validations failures (errorCount === 0) it logs a success message; otherwise, it throws an exception detailing how many checks failed.

These improvements help manage edge cases such as uninitialised references more gracefully, avoiding runtime TypeScript errors during evaluation.

@liuruibin liuruibin merged commit 32b7aa9 into main Feb 26, 2025
4 of 5 checks passed
@liuruibin liuruibin deleted the pr@main@fix_variable_ branch February 26, 2025 09:43
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.

3 participants