From 0bd781be4735169685473f7e3969c6a45f6c0b3e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Mar 2019 15:11:11 +0100 Subject: [PATCH] [fix] Small issue with optional arguments... c.f. issue 1261 --- src/yunohost/app.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index f21352fc2..8f2de0caa 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -2257,13 +2257,17 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None): elif arg_default is not None: arg_value = arg_default - # Validate argument value - if (arg_value is None or arg_value == '') \ - and not arg.get('optional', False): - raise YunohostError('app_argument_required', name=arg_name) - elif arg_value is None: - args_dict[arg_name] = '' - continue + # If the value is empty (none or '') + # then check if arg is optional or not + if arg_value is None or arg_value == '': + if arg.get("optional", False): + # Argument is optional, keep an empty value + # and that's all for this arg ! + args_dict[arg_name] = '' + continue + else: + # The argument is required ! + raise YunohostError('app_argument_required', name=arg_name) # Validate argument choice if arg_choices and arg_value not in arg_choices: