You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
meta: refactor schema versioning to improve errors
This greatly improves the quality of the validating error messages.
Improvement of error messages comes with a minor downside, as from
now on schema validation for meta would not pass on empty files. Users
will have to either put real content in meta files to pass schema
validation, such as version at least to pass. That was needed for
technical reasons as without it the error messages would be
considerably less easy to understand.
Related: python-jsonschema/jsonschema#1002
Copy file name to clipboardExpand all lines: negative_test/roles/meta/main.yml.md
+8-38
Original file line number
Diff line number
Diff line change
@@ -12,29 +12,13 @@
12
12
"schemaPath": "#/properties/galaxy_tags/type"
13
13
},
14
14
{
15
-
"instancePath": "/galaxy_info",
16
-
"keyword": "additionalProperties",
17
-
"message": "must NOT have additional properties",
18
-
"params": {
19
-
"additionalProperty": "min_ansible_version"
20
-
},
21
-
"schemaPath": "#/additionalProperties"
22
-
},
23
-
{
24
-
"instancePath": "/galaxy_info",
25
-
"keyword": "additionalProperties",
26
-
"message": "must NOT have additional properties",
15
+
"instancePath": "",
16
+
"keyword": "if",
17
+
"message": "must match \"then\" schema",
27
18
"params": {
28
-
"additionalProperty": "galaxy_tags"
19
+
"failingKeyword": "then"
29
20
},
30
-
"schemaPath": "#/additionalProperties"
31
-
},
32
-
{
33
-
"instancePath": "",
34
-
"keyword": "anyOf",
35
-
"message": "must match a schema in anyOf",
36
-
"params": {},
37
-
"schemaPath": "#/anyOf"
21
+
"schemaPath": "#/if"
38
22
}
39
23
]
40
24
```
@@ -49,23 +33,9 @@ stdout:
49
33
"errors": [
50
34
{
51
35
"filename": "negative_test/roles/meta/main.yml",
52
-
"path": "$",
53
-
"message": "{'galaxy_info': {'description': 'bar', 'min_ansible_version': '2.9', 'company': 'foo', 'license': 'MIT', 'galaxy_tags': 'database', 'platforms': [{'name': 'Alpine', 'versions': ['all']}]}} is not valid under any of the given schemas",
54
-
"has_sub_errors": true,
55
-
"best_match": {
56
-
"path": "$.galaxy_info",
57
-
"message": "Additional properties are not allowed ('galaxy_tags', 'min_ansible_version' were unexpected)"
58
-
},
59
-
"sub_errors": [
60
-
{
61
-
"path": "$.galaxy_info.galaxy_tags",
62
-
"message": "'database' is not of type 'array'"
63
-
},
64
-
{
65
-
"path": "$.galaxy_info",
66
-
"message": "Additional properties are not allowed ('galaxy_tags', 'min_ansible_version' were unexpected)"
"message": "{'collections': ['foo'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not valid under any of the given schemas",
54
-
"has_sub_errors": true,
55
-
"best_match": {
56
-
"path": "$.galaxy_info",
57
-
"message": "Additional properties are not allowed ('min_ansible_version' was unexpected)"
58
-
},
59
-
"sub_errors": [
60
-
{
61
-
"path": "$.collections[0]",
62
-
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'"
63
-
},
64
-
{
65
-
"path": "$.collections[0]",
66
-
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'"
67
-
},
68
-
{
69
-
"path": "$.galaxy_info",
70
-
"message": "Additional properties are not allowed ('min_ansible_version' was unexpected)"
71
-
}
72
-
]
36
+
"path": "$.collections[0]",
37
+
"message": "'foo' does not match '^[a-z_]+\\\\.[a-z_]+$'",
"message": "{'collections': ['FOO.BAR'], 'galaxy_info': {'description': 'foo', 'license': 'bar', 'min_ansible_version': '2.10', 'platforms': [{'name': 'Fedora', 'versions': ['all']}]}} is not valid under any of the given schemas",
54
-
"has_sub_errors": true,
55
-
"best_match": {
56
-
"path": "$.galaxy_info",
57
-
"message": "Additional properties are not allowed ('min_ansible_version' was unexpected)"
58
-
},
59
-
"sub_errors": [
60
-
{
61
-
"path": "$.collections[0]",
62
-
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'"
63
-
},
64
-
{
65
-
"path": "$.collections[0]",
66
-
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'"
67
-
},
68
-
{
69
-
"path": "$.galaxy_info",
70
-
"message": "Additional properties are not allowed ('min_ansible_version' was unexpected)"
71
-
}
72
-
]
36
+
"path": "$.collections[0]",
37
+
"message": "'FOO.BAR' does not match '^[a-z_]+\\\\.[a-z_]+$'",
0 commit comments