Return 200 instead of 201 when content upload returns existing content unit
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 598
- Forks
- 168
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 86
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in content.py at SingleArtifactContentSerializer.create(), where the created boolean is tracked, then trace how ContentViewSet and SingleArtifactContentUploadViewSet return responses. Verify that retrieved duplicates produce 200 OK while newly created content produces 201 Created, including behavior for plugins that implement retrieve().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100