@@ -14,7 +14,6 @@ class Validator:
1414 MAX_VALIDATION_ERRORS_TO_DISPLAY = 10
1515 MAX_VALIDATE_TASK_QUEUE_SIZE = 100
1616 DEFAULT_VALIDATION_METHODS = ["schema" , "descriptors" , "uniqueness" ]
17- DEFAULT_FAIL_FAST_THRESHOLD = 10
1817
1918 EDFI_GENERICS_TO_RESOURCES_MAPPING = {
2019 "educationOrganizations" : ["localEducationAgencies" , "stateEducationAgencies" , "schools" ],
@@ -35,7 +34,7 @@ def __init__(self, lightbeam=None):
3534 def validate (self ):
3635
3736 # The below should go in __init__(), but rely on lightbeam.config which is not yet available there.
38- self .fail_fast_threshold = self .lightbeam .config .get ("validate" ,{}).get ("references" ,{}).get ("max_failures" , self . DEFAULT_FAIL_FAST_THRESHOLD )
37+ self .fail_fast_threshold = self .lightbeam .config .get ("validate" ,{}).get ("references" ,{}).get ("max_failures" , None )
3938 self .validation_methods = self .lightbeam .config .get ("validate" ,{}).get ("methods" ,self .DEFAULT_VALIDATION_METHODS )
4039 if type (self .validation_methods )== str and (self .validation_methods == "*" or self .validation_methods .lower ()== 'all' ):
4140 self .validation_methods = self .DEFAULT_VALIDATION_METHODS
@@ -219,7 +218,7 @@ async def validate_endpoint(self, endpoint):
219218 self .lightbeam .metadata ["resources" ][endpoint ]["records_failed" ] = self .lightbeam .num_errors
220219
221220 # implement "fail fast" feature:
222- if self .lightbeam .num_errors >= self .fail_fast_threshold :
221+ if self .fail_fast_threshold is not None and self . lightbeam .num_errors >= self .fail_fast_threshold :
223222 self .lightbeam .shutdown ("validate" )
224223 self .logger .critical (f"... STOPPING; found { self .lightbeam .num_errors } >= validate.references.max_failures={ self .fail_fast_threshold } VALIDATION ERRORS." )
225224 break
@@ -235,7 +234,7 @@ async def validate_endpoint(self, endpoint):
235234
236235
237236 async def do_validate_payload (self , endpoint , file_name , data , line_counter ):
238- if self .lightbeam .num_errors >= self .fail_fast_threshold : return
237+ if self .fail_fast_threshold is not None and self . lightbeam .num_errors >= self .fail_fast_threshold : return
239238 definition = self .get_swagger_definition_for_endpoint (endpoint )
240239 if "Descriptor" in endpoint :
241240 swagger = self .lightbeam .api .descriptors_swagger
@@ -251,7 +250,7 @@ async def do_validate_payload(self, endpoint, file_name, data, line_counter):
251250
252251 resolver = RefResolver ("test" , swagger , swagger )
253252 validator = Draft4Validator (resource_schema , resolver = resolver )
254- params_structure = self .lightbeam .api .get_params_for_endpoint (endpoint )
253+ identity_params_structure = self .lightbeam .api .get_params_for_endpoint (endpoint , type = 'identity' )
255254 distinct_params = []
256255
257256 # check payload is valid JSON
@@ -281,7 +280,7 @@ async def do_validate_payload(self, endpoint, file_name, data, line_counter):
281280
282281 # check natural keys are unique
283282 if "uniqueness" in self .validation_methods :
284- params = json .dumps (util .interpolate_params (params_structure , payload ))
283+ params = json .dumps (util .interpolate_params (identity_params_structure , payload ))
285284 params_hash = hashlog .get_hash (params )
286285 if params_hash in distinct_params :
287286 self .log_validation_error (endpoint , file_name , line_counter , "uniqueness" , "duplicate value(s) for natural key(s): {params}" )
@@ -344,6 +343,8 @@ def has_invalid_descriptor_values(self, payload, path=""):
344343 value = self .has_invalid_descriptor_values (payload [k ][i ], path + ("." if path != "" else "" )+ k + "[" + str (i )+ "]" )
345344 if value != "" : return value
346345 elif isinstance (payload [k ], str ) and k .endswith ("Descriptor" ):
346+ if "#" not in payload [k ]:
347+ return payload [k ] + f" is not a valid descriptor value for { k } " + (" (at " + path + ")" if path != "" else "" ) + "; format should be like `uri://namespace.org/SomeDescriptor#SomeValue`"
347348 namespace = payload [k ].split ("#" )[0 ]
348349 codeValue = payload [k ].split ("#" )[1 ]
349350 # check if it's a local descriptor:
0 commit comments