diff --git a/src/ert/config/parsing/config_schema_item.py b/src/ert/config/parsing/config_schema_item.py index 8c6c44ce698..e8a893cb941 100644 --- a/src/ert/config/parsing/config_schema_item.py +++ b/src/ert/config/parsing/config_schema_item.py @@ -222,27 +222,26 @@ def apply_constraints( if self.argc_max == 1 and self.argc_min == 1: return args_with_context[0] - if args: - if keyword == "QUEUE_OPTION" and args[-1] == "$ERT_LSF_SERVER": - raise ConfigValidationError.with_context( + if keyword == "QUEUE_OPTION" and value_with_context == "$ERT_LSF_SERVER": + raise ConfigValidationError.with_context( + ( + "Enviroment variable $ERT_LSF_SERVER does not exist. The" + " LSF_SERVER options is usually " + " specified in the site config file." + ), + value_with_context, + ) + if value_with_context.startswith("$"): + warnings.warn( + ConfigWarning.with_context( ( - "Enviroment variable $ERT_LSF_SERVER does not exist. The" - " LSF_SERVER options is usually " - " specified in the site config file." + f"Environment variable {value_with_context} may not be" + " defined." ), value_with_context, - ) - if args[-1].startswith("$"): - warnings.warn( - ConfigWarning.with_context( - ( - f"Environment variable {value_with_context} may not be" - " defined." - ), - value_with_context, - ), - stacklevel=1, - ) + ), + stacklevel=1, + ) return args_with_context