reveal bad value when job conf validation fails

This commit is contained in:
Noah Levitt 2019-12-04 15:11:53 -08:00
parent 060adaffd0
commit 597f2b5b33
2 changed files with 11 additions and 4 deletions

View File

@ -43,13 +43,20 @@ class JobValidator(cerberus.Validator):
return url.scheme in ('http', 'https', 'ftp')
class InvalidJobConf(Exception):
def __init__(self, errors):
self.errors = errors
def __init__(self, validator):
self.errors = validator.errors
try:
# Cerberus does a nice job hiding the bad value. In the case I
# debugged, I found it here. Maybe there's a better way to see it.
value = validator._errors[0].info[0][0].info[0][0].value
self.errors['bad value'] = value
except:
value = None
def validate_conf(job_conf, schema=load_schema()):
v = JobValidator(schema)
if not v.validate(job_conf, normalize=False):
raise InvalidJobConf(v.errors)
raise InvalidJobConf(v)
def merge(a, b):
if isinstance(a, dict) and isinstance(b, dict):

View File

@ -32,7 +32,7 @@ def find_package_data(package):
setuptools.setup(
name='brozzler',
version='1.5.16',
version='1.5.17',
description='Distributed web crawling with browsers',
url='https://github.com/internetarchive/brozzler',
author='Noah Levitt',