Azure / Azure/azure-cli

[AKS] code bug in _handle_merge which impacts aks_get_credentials

Open
#17,690 1 comment 0 reactions 0 assignees View on GitHub
act-observability-squad AKS Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

The below code deletes elements in `existing[key]` while looping through it, this would cause a skip of the element right after the one that is deleted (as the iterator will advance when deleting happens) and will cause bugs if two consecutive items need to be deleted.
https://github.com/Azure/azure-cli/blob/3226fae922e423cdc46bf3bf6f14ac9e57a66ea0/src/azure-cli/azure/cli/command_modules/acs/custom.py#L1108-L1114

Run the below python code to show the bug:
```
list=[1,2,3,4]
for n in list:
list.remove(n)
print(list) # the result is [2,4] instead of []
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.