Skip to content

Commit

Permalink
Remove overly aggressive exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna committed Feb 13, 2023
1 parent b9208b1 commit 39a3f5f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions dandiapi/api/services/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ def validate_asset_metadata(*, asset: Asset) -> None:

validation_errors = _collect_validation_errors(e)
asset.validation_errors = validation_errors
except ValueError as e:
# A bare ValueError is thrown when dandischema generates its own exceptions, like a
# mismatched schemaVersion.
asset.status = Asset.Status.INVALID
asset.validation_errors = [{'field': '', 'message': str(e)}]

# Save asset
asset.save()
Expand All @@ -73,14 +68,9 @@ def version_aggregate_assets_summary(version: Version):
if version.version != 'draft':
raise VersionHasBeenPublished()

try:
version.metadata['assetsSummary'] = aggregate_assets_summary(
version.assets.values_list('metadata', flat=True).iterator()
)
except Exception:
# The assets summary aggregation may fail if any asset metadata is invalid, skip
# updating it if it fails.
logger.info('Error calculating assetsSummary', exc_info=True)
version.metadata['assetsSummary'] = aggregate_assets_summary(
version.assets.values_list('metadata', flat=True).iterator()
)

Version.objects.filter(id=version.id, version='draft').update(
modified=timezone.now(), metadata=version.metadata
Expand Down

0 comments on commit 39a3f5f

Please sign in to comment.