fix: Handle null undrainable_node_behavior in precondition validation#762
Open
raman1236 wants to merge 1 commit intoAzure:mainfrom
Open
fix: Handle null undrainable_node_behavior in precondition validation#762raman1236 wants to merge 1 commit intoAzure:mainfrom
raman1236 wants to merge 1 commit intoAzure:mainfrom
Conversation
Fixes Azure#760 When upgrade_settings.undrainable_node_behavior is explicitly set to null, the contains() function fails because it cannot accept null as the value parameter. Wrapping the contains() call in try() handles this case gracefully.
44c4ee0 to
9d0188b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #760
Description
When
upgrade_settings.undrainable_node_behavioris explicitly set tonull, thecontains()function in the precondition validation fails with:This happens because
try(each.value.upgrade_settings.undrainable_node_behavior, "")succeeds (the attribute exists, it's just null), socontains()receives null instead of a string.Fix
Wrap the entire
contains()call intry(..., false)so that if the value is null, the function call fails gracefully and the precondition evaluates tofalse— but since the middle condition (== null) already short-circuits, this branch is only reached for non-null values.Testing
Validated that:
undrainable_node_behavior = null→ no error (short-circuits at middle condition)undrainable_node_behavior = "Cordon"→ passes validationundrainable_node_behavior = "invalid"→ fails with proper error message