Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if version still exists before proceeding with validation #1808

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading