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 mdellweg committed May 10, 2023
1 parent 91dd577 commit dba8dd1
Show file tree
Hide file tree
Showing 3 changed files with 4 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
1 change: 1 addition & 0 deletions functest_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pulp-smash @ git+https://github.com/pulp/pulp-smash.git
ansible-core!=2.13.9,!=2.14.5
orionutils
pytest
dynaconf
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 dba8dd1

Please sign in to comment.