Skip to content
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

{servicebus} Fix error message raised on a malformed ISO-8601 duration #23037

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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