Skip to content

Commit

Permalink
Serializer.validate must return validated data. Fixes #1441 (#1432)
Browse files Browse the repository at this point in the history
(cherry picked from commit 69e2017)
  • Loading branch information
sivel authored and patchback[bot] committed May 9, 2023
1 parent 4f75527 commit ac08e5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/1441.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix traceback when publishing a collection to the v2 API endpoint
2 changes: 2 additions & 0 deletions pulp_ansible/app/galaxy/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ class GalaxyCollectionUploadSerializer(serializers.Serializer):

def validate(self, data):
"""Ensure duplicate artifact isn't uploaded."""
data = super().validate(data)
sha256 = data["file"].hashers["sha256"].hexdigest()
artifact = Artifact.objects.filter(sha256=sha256).first()
if artifact:
raise serializers.ValidationError(_("Artifact already exists"))
return data

0 comments on commit ac08e5d

Please sign in to comment.