Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@LilDojd This change looks good. Can you rebase so that CI goes green? |
|
Related issue: (I think for pulp_file) pulp/pulpcore#6919 |
The Google Cloud Storage backend sets the name of the saved file object to its storage path. The upload serializer read file.name after it saved the artifact, so the upload task got the storage path instead of the package filename. The task then failed to find a known extension, and the upload was lost. The serializer now reads the filename before it saves the artifact. Assisted By: Claude Code (claude-opus-5-5)
09637bd to
9de0926
Compare
|
@gerrod3 rebased, thanks! |
| serializer = PackageUploadSerializer( | ||
| data={ | ||
| "content": PulpTemporaryUploadedFile.from_file(ContentFile(payload, name=filename)), | ||
| "sha256_digest": hashlib.sha256(payload).hexdigest(), | ||
| } | ||
| ) | ||
| with mock.patch.object(storage, "_save", side_effect=save_and_rename): | ||
| self.assertTrue(serializer.is_valid(), serializer.errors) | ||
|
|
||
| artifact, uploaded_filename = serializer.validated_data["content"] | ||
| self.assertEqual(uploaded_filename, filename) | ||
| self.assertNotEqual(artifact.file.name, filename) |
There was a problem hiding this comment.
The last assert passes regardless of the mock, because the artiifact storage path never equals filename. Could you please change it to check the upload object instead? That confirms the mocked _save actually ran and renamed the file:
upload = PulpTemporaryUploadedFile.from_file(ContentFile(payload, name=filename))
serializer = PackageUploadSerializer(
data={
"content": upload,
"sha256_digest": hashlib.sha256(payload).hexdigest(),
}
)
with mock.patch.object(storage, "_save", side_effect=save_and_rename):
self.assertTrue(serializer.is_valid(), serializer.errors)
_, uploaded_filename = serializer.validated_data["content"]
self.assertEqual(uploaded_filename, filename)
self.assertNotEqual(upload.name, filename)
| if action != "file_upload": | ||
| raise serializers.ValidationError(_("We do not support the :action {}").format(action)) | ||
| file = data.get("content") | ||
| # Remote storage backends rename the file when the artifact is saved. |
There was a problem hiding this comment.
Could you please specify Google Cloud Storage in the comment?
The Google Cloud Storage backend sets the name of the saved file object to its storage path. The upload serializer read file.name after it saved the artifact, so the upload task got the storage path instead of the package filename. The task then failed to find a known extension, and the upload was lost. The serializer now reads the filename before it saves the artifact.
Assisted By: Claude Code (claude-opus-5-5)
📜 Checklist
See: Pull Request Walkthrough
Summary by CodeRabbit