mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 03:10:42 -03:30
Merge pull request #1806 from AlanCoding/660_extra_vars_nondict
Raise error when runtime extra_vars are not dictionaries
This commit is contained in:
commit
11796ade45
@ -2234,8 +2234,9 @@ class JobLaunchSerializer(BaseSerializer):
|
||||
except (ValueError, TypeError):
|
||||
try:
|
||||
extra_vars = yaml.safe_load(extra_vars)
|
||||
except (yaml.YAMLError, TypeError, AttributeError):
|
||||
errors['extra_vars'] = 'Must be valid JSON or YAML'
|
||||
assert isinstance(extra_vars, dict)
|
||||
except (yaml.YAMLError, TypeError, AttributeError, AssertionError):
|
||||
errors['extra_vars'] = 'Must be a valid JSON or YAML dictionary'
|
||||
|
||||
if not isinstance(extra_vars, dict):
|
||||
extra_vars = {}
|
||||
|
||||
@ -159,7 +159,7 @@ def test_job_reject_invalid_prompted_extra_vars(runtime_data, job_template_promp
|
||||
dict(extra_vars='{"unbalanced brackets":'), user('admin', True))
|
||||
|
||||
assert response.status_code == 400
|
||||
assert response.data['extra_vars'] == ['Must be valid JSON or YAML']
|
||||
assert response.data['extra_vars'] == ['Must be a valid JSON or YAML dictionary']
|
||||
|
||||
@pytest.mark.django_db
|
||||
@pytest.mark.job_runtime_vars
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user