From 58e84a40e5abbc5fb5dc5e498cbcb5feed2cda83 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 23 Oct 2019 14:22:07 -0400 Subject: [PATCH] Fix 500 error when creating a job schedule - 500 error occurs when a non-admin user attempts to add an invalid credential during schedule creation - This change checks that the user can add the object to serializer.validated_data, instead of serializer.initial_data - The invalid credential field is purged in .validated_data, so the request passes through cleanly - Fix for awx issue #4147 --- awx/api/generics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/api/generics.py b/awx/api/generics.py index f251a63246..37ca8bef42 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -574,7 +574,7 @@ class SubListCreateAPIView(SubListAPIView, ListCreateAPIView): status=status.HTTP_400_BAD_REQUEST) # Verify we have permission to add the object as given. - if not request.user.can_access(self.model, 'add', serializer.initial_data): + if not request.user.can_access(self.model, 'add', serializer.validated_data): raise PermissionDenied() # save the object through the serializer, reload and returned the saved