From 8e16b69344e1afcb49afc65e7bda63a139beaa31 Mon Sep 17 00:00:00 2001 From: Qinkai Wu <32201005+ReaNAiveD@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:55:02 +0800 Subject: [PATCH] {Interactive} Fix Scenario Idx out of bound when selecting recommended scenario (#6535) * Fix Scenario Idx out of bound when selecting recommended scenario * Add message in `HISTORY.rst` --- src/interactive/HISTORY.rst | 1 + src/interactive/azext_interactive/azclishell/app.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interactive/HISTORY.rst b/src/interactive/HISTORY.rst index b114f5c47b3..9d79b249753 100644 --- a/src/interactive/HISTORY.rst +++ b/src/interactive/HISTORY.rst @@ -5,6 +5,7 @@ Release History upcoming +++++ +* Fix Scenario Idx out of bound when selecting recommended scenario * Add command skipped message in Scenario Execution Mode 0.5.1 diff --git a/src/interactive/azext_interactive/azclishell/app.py b/src/interactive/azext_interactive/azclishell/app.py index 72c2d820a94..230c8c2de6a 100644 --- a/src/interactive/azext_interactive/azclishell/app.py +++ b/src/interactive/azext_interactive/azclishell/app.py @@ -536,11 +536,11 @@ def handle_scenario(self, text): # e.g. :: 1 => `selected_option='1'` selected_option = text.partition(SELECT_SYMBOL['example'])[2].strip() try: - selected_option = int(selected_option) + selected_option = int(selected_option) - 1 except ValueError: print("An Integer should follow the colon", file=self.output) return - if 0 <= selected_option <= len(self.recommender.get_scenarios() or []): + if 0 <= selected_option < len(self.recommender.get_scenarios() or []): scenario = self.recommender.get_scenarios()[selected_option] self.recommender.feedback_scenario(selected_option, scenario) else: