-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{Monitor}Bug fix for stop iteration #12800
Conversation
@Juliehzl @arrownj @haroldrandom Is there any better way to fix it? I mean more native in python. |
src/azure-cli/azure/cli/command_modules/monitor/operations/autoscale_settings.py
Outdated
Show resolved
Hide resolved
profile_names = [x.name for x in autoscale_settings.profiles] | ||
if not profile_name in profile_names: | ||
from knack.util import CLIError | ||
raise CLIError('Profile name is invalid. Please check the existence of the profile.') | ||
profile = next(x for x in autoscale_settings.profiles if x.name == profile_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative is to use try...except sinppet to catch StopIteration error, then raise CLIError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well. So next
cannot handle such scenario and we need extra logic. Right? Compared to try..except, I prefer current one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using try..except is the same what you did now.
src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_autoscale.py
Outdated
Show resolved
Hide resolved
62f81ca
to
82400f4
Compare
Fix #12191
Description of PR (Mandatory)
(Why this PR? What is changed? What is the effect? etc. A high-quality description can accelerate the review process)
Testing Guide
(Example commands with explanations)
History Notes:
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)
[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.