Problem Statement
When uploading content that already exists (duplicate), SingleArtifactContentSerializer.create() calls retrieve() and returns the existing content unit. However, the HTTP response is always 201 Created, even when no new resource was created. This is misleading.
Current Behavior
Both ContentViewSet (via CreateModelMixin) and SingleArtifactContentUploadViewSet always return 201, regardless of whether the content was newly created or retrieved from an existing duplicate.
Expected Behavior
Return 200 OK when the content unit already exists (retrieved via retrieve()), and 201 Created only when a new content unit is actually created.
Implementation Notes
SingleArtifactContentSerializer.create() already tracks a created boolean (line ~109 in content.py). This flag needs to be propagated to the viewset layer so it can choose the appropriate HTTP status code. This would benefit all plugins that implement retrieve() (pulp_rpm, pulp_maven, etc.) without requiring per-plugin changes.
Related: pulp/pulp_maven#363
Problem Statement
When uploading content that already exists (duplicate),
SingleArtifactContentSerializer.create()callsretrieve()and returns the existing content unit. However, the HTTP response is always 201 Created, even when no new resource was created. This is misleading.Current Behavior
Both
ContentViewSet(viaCreateModelMixin) andSingleArtifactContentUploadViewSetalways return 201, regardless of whether the content was newly created or retrieved from an existing duplicate.Expected Behavior
Return 200 OK when the content unit already exists (retrieved via
retrieve()), and 201 Created only when a new content unit is actually created.Implementation Notes
SingleArtifactContentSerializer.create()already tracks acreatedboolean (line ~109 incontent.py). This flag needs to be propagated to the viewset layer so it can choose the appropriate HTTP status code. This would benefit all plugins that implementretrieve()(pulp_rpm, pulp_maven, etc.) without requiring per-plugin changes.Related: pulp/pulp_maven#363