-
Task
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
False
-
False
-
None
-
Undefined
-
-
AAH 4.3.0 Sprint 1, AAH 4.3.0 Sprint 2
Related discussion: https://github.com/ansible/galaxy_ng/pull/562#discussion_r520698907
Problems:
- On galaxy_ng/app/api/v3/viewsets/namespace.py there is a `create` method which creates 2 instances (repo and distro) and also validates for IntegrityError expecting error for unique name constraints.
- The validation there uses a try:except introduced by the PR 562 and this error catching are too general and can lead to exception swallowing if integrity occurs related to a different field.
- On galaxy_ng/app/api/v3/serializers/namespace.py there is also a `create` method and a `validate_name` which is also performing some creation and validation.
Proposed solutions:
- Create a common `create_or_raise` method to be used on every instance creation and then centralizing validation.
- Move the creation of the 3 entities to the same place on the Serializer and after the validator is performed *recommended*
- apply ScopedErrorSerializer https://github.com/ansible/galaxy_ng/blob/master/galaxy_ng/app/api/v3/serializers/namespace.py#L17