Skip to content

Commit 3e162d9

Browse files
authored
Merge pull request #493 from hubmapconsortium/kburke/collectionAsEntityPatchFromSN
Small change to keep code aligned with SenNet, which logs and returns…
2 parents 7ab8db0 + 4a065eb commit 3e162d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/schema/schema_validators.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,19 @@ def verify_DOI_pair(property_key, normalized_entity_type, request, existing_data
133133
# Since both DOI parameters are present, make sure neither is the empty string
134134
if new_data_dict['doi_url'] == '' or new_data_dict['registered_doi'] == '':
135135
raise ValueError( f"The properties 'doi_url' and 'registered_doi' cannot be empty, when specified.")
136+
136137
# Check if doi_url matches registered_doi with the expected prefix
137-
if new_data_dict['doi_url'] != SchemaConstants.DOI_BASE_URL + new_data_dict['registered_doi']:
138+
try:
139+
expected_doi_url = SchemaConstants.DOI_BASE_URL + new_data_dict['registered_doi']
140+
except Exception as e:
141+
# If SchemaConstants.DOI_BASE_URL is not set, or there is some other
142+
# problem, give up and fail this validation.
143+
logger.error(f"During verify_DOI_pair schema validator, unexpected exception e={str(e)}")
144+
raise ValueError(f"An unexpected error occurred during evaluation of DOI parameters. See logs.")
145+
if expected_doi_url and new_data_dict['doi_url'] != expected_doi_url:
138146
raise ValueError( f"The 'doi_url' property should match the 'registered_doi' property, after"
139147
f" the prefix {SchemaConstants.DOI_BASE_URL}.")
148+
140149
"""
141150
Validate every entity in a list is of entity_type accepted
142151

0 commit comments

Comments
 (0)