Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: In the variable aggregation strategy that returns the first non-null value of each group, empty strings, empty lists, and empty objects are not treated as null values

…null value of each group, empty strings, empty lists, and empty objects are not treated as null values
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 29, 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.

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 Oct 29, 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.

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

if v is not None and not(isinstance(v, (str,list,dict)) and len(v) == 0) :
return v
return None

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 has a few minor issues and improvements that can be made:

  1. Redundant Condition: The current condition if isinstance(v, (str,list,dict)) and len(v) == 0 is redundant because an empty string ('') or other falsy values won't evaluate to True. Therefore, you can simplify this part of the check to just v is not None.

  2. Line Length: There's one line too long, which might make it harder to read. You can break the line using parentheses or a backslash.

  3. Whitespace Improvements: Ensure consistent indentation to maintain readability.

Here's the improved version:

def get_first_non_null(self, variable_list):
    for variable in variable_list:
        ref_var = self.workflow_manage.get_reference_field(
            variable.get('variable')[0],
            variable.get('variable')[1:]
        )
        if ref_var is not None:
            return ref_var
    return None

Note: This assumes that ref_var returned from get_reference_field() cannot be considered "null" in the sense defined by checking its truthiness after stripping whitespace if needed (though strings are inherently non-empty in Python). If that assumption changes, additional checks should be implemented accordingly.

@zhanweizhang7 zhanweizhang7 merged commit 2cf1ad7 into v2 Oct 29, 2025
4 of 6 checks passed
@zhanweizhang7 zhanweizhang7 deleted the pr@v2@fix_variable_type branch October 29, 2025 07:34
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