Skip to content

Commit

Permalink
Check if version has been deleted before continuing with validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh committed Jan 4, 2024
1 parent b9efde8 commit e98a172
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dandiapi/api/services/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ def _build_validatable_version_metadata(version: Version) -> dict:
}
return metadata_for_validation

logger.info('Validating dandiset metadata for version %s', version.id)
version_id = version.id

logger.info('Validating dandiset metadata for version %s', version_id)

# Published versions are immutable
if version.version != 'draft':
Expand All @@ -134,6 +136,13 @@ def _build_validatable_version_metadata(version: Version) -> dict:
.select_for_update()
.first()
)

# It's possible for this version to get deleted during execution of this function.
# If that happens *before* the select_for_update query, return early.
if version is None:
logger.info('Version %s no longer exists, skipping validation', version_id)
return

version.status = Version.Status.VALIDATING
version.save()

Expand Down

0 comments on commit e98a172

Please sign in to comment.