Skip to content

Return 200 instead of 201 when content upload returns existing content unit #7820

Description

@dkliban

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions