From 9447c092acff54c3449ebdad26b29b3f302e5213 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 26 Jan 2015 10:12:26 -0500 Subject: [PATCH] Fix a 500 error when posting empty json to the config endpoint, this code was just wrong --- awx/api/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/awx/api/views.py b/awx/api/views.py index 050e0d8f16..7f7f072d31 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -207,15 +207,15 @@ class ApiV1ConfigView(APIView): def post(self, request): if not request.user.is_superuser: return Response(None, status=status.HTTP_404_NOT_FOUND) - if "eula_accepted" not in request.DATA: - return Response({"error": "Missing 'eula_accepted' property"}, status=status.HTTP_400_BAD_REQUEST) - if not request.DATA["eula_accepted"]: - return Response({"error": "'eula_accepted' must be True"}, status=status.HTTP_400_BAD_REQUEST) - request.DATA.pop("eula_accepted") try: data_actual = json.dumps(request.DATA) except Exception, e: return Response({"error": "Invalid JSON"}, status=status.HTTP_400_BAD_REQUEST) + if "eula_accepted" not in data_actual: + return Response({"error": "Missing 'eula_accepted' property"}, status=status.HTTP_400_BAD_REQUEST) + if not data_actual["eula_accepted"]: + return Response({"error": "'eula_accepted' must be True"}, status=status.HTTP_400_BAD_REQUEST) + data_actual.pop("eula_accepted") license_reader = TaskSerializer() try: license_data = license_reader.from_string(data_actual)