From 16026226fb2e9746f65d53afcac4bf708bbd279f Mon Sep 17 00:00:00 2001 From: RakeshMohan-MSFT <49954584+RakeshMohanMSFT@users.noreply.github.com> Date: Wed, 29 Jun 2022 07:58:55 +0530 Subject: [PATCH] {servicebus} Fix error message raised on a malformed ISO-8601 duration (#23037) * {servicebus} | Fixing error message raised on a malformed ISO-8601 duration Fixes https://github.com/Azure/azure-cli/issues/23013 * {Service Bus} | Correct namespace issue Correct namespace issue * {servicebus} | updated relevant error type updated relevant error type * {servicebus} | Correcting syntax Correcting syntax --- .../azure/cli/command_modules/servicebus/custom.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/azure-cli/azure/cli/command_modules/servicebus/custom.py b/src/azure-cli/azure/cli/command_modules/servicebus/custom.py index b610503717e..b6aaeb9b4a5 100644 --- a/src/azure-cli/azure/cli/command_modules/servicebus/custom.py +++ b/src/azure-cli/azure/cli/command_modules/servicebus/custom.py @@ -618,6 +618,7 @@ def return_valid_duration(update_value, current_value=None): from datetime import timedelta from isodate import parse_duration from isodate import Duration + from azure.cli.core.azclierror import InvalidArgumentValueError from azure.cli.command_modules.servicebus.constants import DURATION_SECS, DURATION_MIN, DURATION_DAYS if update_value is not None: value_toreturn = update_value @@ -625,7 +626,10 @@ def return_valid_duration(update_value, current_value=None): return current_value if iso8601pattern.match(value_toreturn): - time_duration = parse_duration(value_toreturn) + try: + time_duration = parse_duration(value_toreturn) + except: + raise InvalidArgumentValueError("Unable to parse provided ISO 8601 format duration %r" % value_toreturn) if isinstance(time_duration, timedelta): if time_duration <= timedelta(days=DURATION_DAYS, minutes=DURATION_MIN, seconds=DURATION_SECS):