Skip to content

Commit 6206fcc

Browse files
Handle missing or invalid concurrency field gracefully during import
1 parent e0cae14 commit 6206fcc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

api/odl2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,12 @@ def _extract_publication_metadata(
223223
if odl_license.metadata.terms
224224
else None
225225
)
226-
concurrency = (
227-
int(odl_license.metadata.terms.concurrency)
228-
if odl_license.metadata.terms
229-
else None
230-
)
226+
try:
227+
# Try to convert the concurrency value to an integer.
228+
concurrency = int(odl_license.metadata.terms.concurrency)
229+
except (AttributeError, ValueError, TypeError):
230+
# If concurrency is missing, not an int, or terms is invalid, default to None.
231+
concurrency = None
231232

232233
if not license_info_document_link:
233234
parsed_license = None

0 commit comments

Comments
 (0)