Skip to content

Commit

Permalink
{servicebus} Fix error message raised on a malformed ISO-8601 duration (
Browse files Browse the repository at this point in the history
#23037)

* {servicebus} | Fixing error message raised on a malformed ISO-8601 duration

Fixes #23013

* {Service Bus} | Correct namespace issue

Correct namespace issue

* {servicebus} | updated relevant error type

updated relevant error type

* {servicebus} | Correcting syntax 

Correcting syntax
  • Loading branch information
RakeshMohanMSFT authored Jun 29, 2022
1 parent ac1759b commit 1602622
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/azure-cli/azure/cli/command_modules/servicebus/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,18 @@ 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
else:
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):
Expand Down

0 comments on commit 1602622

Please sign in to comment.