Issue #3436
closed
Creating duplicate content results in 500 IntegrityError
Status:
CLOSED - CURRENTRELEASE
Description
$ http POST http://localhost:8000/api/v3/content/file/ relative_path=hello.tar.gz artifact="http://localhost:8000/api/v3/artifacts/79993432-e329-4bef-86bb-9bd481cee489/" [392/1963]
HTTP/1.0 201 Created
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 226
Content-Type: application/json
Date: Tue, 06 Mar 2018 19:33:49 GMT
Server: WSGIServer/0.2 CPython/3.5.4
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
{
"_href": "http://localhost:8000/api/v3/content/file/db0dc6fe-d0c0-445c-af08-cd38aa9f4c42/",
"artifact": "http://localhost:8000/api/v3/artifacts/79993432-e329-4bef-86bb-9bd481cee489/",
"relative_path": "hello.tar.gz",
"type": "file"
}
$ http POST http://localhost:8000/api/v3/content/file/ relative_path=hello.tar.gz artifact="http://localhost:8000/api/v3/artifacts/79993432-e329-4bef-86bb-9bd481cee489/"
HTTP/1.0 500 Internal Server Error
Content-Length: 23305
Content-Type: text/plain
Date: Tue, 06 Mar 2018 19:33:53 GMT
Server: WSGIServer/0.2 CPython/3.5.4
Vary: Cookie
X-Frame-Options: SAMEORIGIN
IntegrityError at /api/v3/content/file/
UNIQUE constraint failed: pulp_file_filecontent.relative_path, pulp_file_filecontent.digest
- Severity changed from 2. Medium to 3. High
- Triaged changed from No to Yes
- Tags Pulp 3 added
- Sprint Candidate changed from No to Yes
- Status changed from NEW to ASSIGNED
- Assignee set to CodeHeeler
Adding a checklist item to add a pulp-smash issue.
- Related to Test #4125: Test if creating duplicate content results in 400 added
I added a test case for this issue.
- Status changed from ASSIGNED to NEW
- Assignee deleted (
CodeHeeler)
What is the expected behave here?
Not a 500 error. Probably a 400.
Removed checklist item since there is a related issue
- Sprint changed from Sprint 34 to Sprint 46
- Status changed from NEW to ASSIGNED
- Assignee set to daviddavis
- Status changed from ASSIGNED to POST
- Status changed from POST to MODIFIED
If the same artifact is used by with different relative_path no 400 HTTP Error is raised. It that the expected behaviour?
2 different content units using the same artifact and 2 different relative_path.
{'_href': '/pulp/api/v3/content/file/files/16/',
'artifact': '/pulp/api/v3/artifacts/13/',
'created': '2018-12-19T18:30:50.562582Z',
'relative_path': '4d12bb9d-82a5-4f07-ad41-1dfe9e9140da',
'type': 'file'}
{'_href': '/pulp/api/v3/content/file/files/17/',
'artifact': '/pulp/api/v3/artifacts/13/',
'created': '2018-12-19T18:30:50.670502Z',
'relative_path': '0e512076-e7f7-4502-8d21-83d30fe60aa4',
'type': 'file'}
If the same artifact is used by with different relative_path no 400 HTTP Error is raised. It that the expected behaviour?
That's correct. Artifacts are unique by relative_path and file. This would be same file with two different names for example.
- Sprint/Milestone set to 0.1.0
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Also available in: Atom
PDF
Fixing duplicate content exception
fixes #3436 https://pulp.plan.io/issues/3436