From 07807c2decd82e01dc0a2047d21aba92114555b0 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 27 Feb 2020 14:37:29 -0500 Subject: [PATCH] Fail on launch for scenario where job cannot run --- awx/api/serializers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 93124ea19e..f4a61f0c43 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -4054,6 +4054,13 @@ class JobLaunchSerializer(BaseSerializer): **attrs) self._ignored_fields = rejected + # Basic validation - cannot run a playbook without a playbook + if not template.project: + errors['project'] = _("A project is required to run a job.") + elif template.project.status in ('error', 'failed'): + errors['playbook'] = _("Missing a revision to run due to failed project update.") + + # cannot run a playbook without an inventory if template.inventory and template.inventory.pending_deletion is True: errors['inventory'] = _("The inventory associated with this Job Template is being deleted.") elif 'inventory' in accepted and accepted['inventory'].pending_deletion: