I am uploading a bunch of Keywords and it turns out that one of them gets flagged for medical policy violation. When then examining the error the location would be 0, i.e.
def get_error_indices(ex):
duplicates = []
policy_errors = []
for error in ex.failure.errors:
if error.location and 'DUPLICATE' in str(error.error_code):
for field_path_element in error.location.field_path_elements:
if field_path_element.field_name == 'operations':
duplicates.append(field_path_element.index.value)
elif error.location and 'POLICY_ERROR' in str(error.error_code):
for field_path_element in error.location.field_path_elements:
if field_path_element.field_name == 'operations':
policy_errors.append(field_path_element.index.value)
return duplicates, policy_errors
I am handling those errors differently in terms of retries and such. the part for duplicates works fine, the part for policy violations not so much.
Cheers