Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Modify the parameter name and display name of the loop variable in the loop node, but the variable name is not updated in the nodes outside the loop

…in the loop node, but the variable name is not updated in the nodes outside the loop
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Dec 10, 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

f2c-ci-robot bot commented Dec 10, 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

loop_node.clear_next_node_field(true)
}
}
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 given code seems to be related to setting and clearing properties of nodes in an application's graph model. It performs the following actions:

  1. Calls refresh_loop_fields with an array of fields as an argument.
  2. Retrieves a node from props.nodeModel.graphModel.getNodeModelById(loop_node_id).
  3. If the retrieved node is not null, it sets the configuration fields of this node to fields.
  4. After updating the node's fields, it calls loop_node.clear_next_node_field(true).

Here are some comments and optimizations to consider:

Comments:

  • The docstring describing these operations would be helpful for understanding what each part does.

Optimization/Suggestions:

  • Ensure that loop_node_properties.config.fields can handle arrays correctly. Adding fields should typically result in appending them to the existing array rather than overwriting it entirely unless there's specific logic preventing updates.
  • Consider if there might be performance implications related to how these functions are called frequently or within intensive loops.

Improved Code Example

const refresh_loop_fields = (fields: Array<any>, loop_node_id: string) => {
  const loop_node = props.nodeModel.graphModel.getNodeModelById(loop_node_Id);
  
  if (!loop_node || !Array.isArray(fields)) return;

  try {
    // Safely set new field values while maintaining existing ones
    loop_node.properties.config.fields.push(...fields);

    // Optionally remove next-node-specific fields after update
    loop_node.clear_next_node_field(true);
  } catch (e) {
    console.error('Error refreshing Loop Fields:', e);
  }
}

This version improves robustness by checking for empty/null conditions early on and includes error handling for cases where things go wrong during execution.

@shaohuzhang1 shaohuzhang1 merged commit 9d23b62 into v2 Dec 10, 2025
3 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch December 10, 2025 05:55
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