mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
filter Python unicode string prefix from jsonschema validation errors.
see: https://github.com/ansible/ansible-tower/issues/6417
This commit is contained in:
@@ -370,7 +370,7 @@ class JSONSchemaField(JSONBField):
|
|||||||
|
|
||||||
# If an empty {} is provided, we still want to perform this schema
|
# If an empty {} is provided, we still want to perform this schema
|
||||||
# validation
|
# validation
|
||||||
empty_values=(None, '')
|
empty_values = (None, '')
|
||||||
|
|
||||||
def get_default(self):
|
def get_default(self):
|
||||||
return copy.deepcopy(super(JSONBField, self).get_default())
|
return copy.deepcopy(super(JSONBField, self).get_default())
|
||||||
@@ -385,6 +385,9 @@ class JSONSchemaField(JSONBField):
|
|||||||
self.schema(model_instance),
|
self.schema(model_instance),
|
||||||
format_checker=self.format_checker
|
format_checker=self.format_checker
|
||||||
).iter_errors(value):
|
).iter_errors(value):
|
||||||
|
# strip Python unicode markers from jsonschema validation errors
|
||||||
|
error.message = re.sub(r'\bu(\'|")', r'\1', error.message)
|
||||||
|
|
||||||
if error.validator == 'pattern' and 'error' in error.schema:
|
if error.validator == 'pattern' and 'error' in error.schema:
|
||||||
error.message = error.schema['error'] % error.instance
|
error.message = error.schema['error'] % error.instance
|
||||||
errors.append(error)
|
errors.append(error)
|
||||||
|
|||||||
Reference in New Issue
Block a user