From 1c374fba7d07eb506404cae7483f97a8c02e3ffe Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Fri, 6 Oct 2017 15:33:20 -0400 Subject: [PATCH] reword error message about encrypted user input --- awx/api/views.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/awx/api/views.py b/awx/api/views.py index 9157901b3b..7574b160a1 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -2900,16 +2900,19 @@ class JobTemplateSurveySpec(GenericAPIView): if survey_item["type"] == "password" and "default" in survey_item: if not isinstance(survey_item['default'], six.string_types): - return Response( - _("Value %s for '%s' expected to be a string." % ( - survey_item["default"], survey_item["variable"] - )), - status=status.HTTP_400_BAD_REQUEST - ) + return Response(dict(error=_( + "Value {question_default} for '{variable_name}' expected to be a string." + ).format( + question_default=survey_item["default"], variable_name=survey_item["variable"]) + ), status=status.HTTP_400_BAD_REQUEST) elif survey_item["default"].startswith('$encrypted$'): if not obj.survey_spec: - return Response(dict(error=_("$encrypted$ is reserved keyword and may not be used as a default for password {}.".format(str(idx)))), - status=status.HTTP_400_BAD_REQUEST) + return Response(dict(error=_( + "$encrypted$ is reserved keyword for password questions and may not " + "be used as a default for '{variable_name}' in survey question {question_position}." + ).format( + variable_name=survey_item["variable"], question_position=str(idx)) + ), status=status.HTTP_400_BAD_REQUEST) else: old_spec = obj.survey_spec for old_item in old_spec['spec']: