diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 0ba7a7694c..0127c95c60 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1866,7 +1866,9 @@ class JobOptionsSerializer(LabelsListMixin, BaseSerializer): job_type = attrs.get('job_type', self.instance and self.instance.job_type or None) if not project and job_type != PERM_INVENTORY_SCAN: raise serializers.ValidationError({'project': _('This field is required.')}) - if project and playbook and force_text(playbook) not in project.playbook_files: + if project and project.scm_type and playbook and force_text(playbook) not in project.playbook_files: + raise serializers.ValidationError({'playbook': _('Playbook not found for project.')}) + if project and not project.scm_type and playbook and force_text(playbook) not in project.playbooks: raise serializers.ValidationError({'playbook': _('Playbook not found for project.')}) if project and not playbook: raise serializers.ValidationError({'playbook': _('Must select playbook for project.')})