Skip to content

Commit

Permalink
Serializer.validate must return validated data. Fixes pulp#1441
Browse files Browse the repository at this point in the history
  • Loading branch information
sivel committed May 9, 2023
1 parent 9ddecd0 commit 929fcd9
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 929fcd9

Please sign in to comment.