fix(plugin-cloud-storage): prevent crop reprocessing during metadata persist#15993
Open
kayareyouokay wants to merge 2 commits intopayloadcms:mainfrom
Open
fix(plugin-cloud-storage): prevent crop reprocessing during metadata persist#15993kayareyouokay wants to merge 2 commits intopayloadcms:mainfrom
kayareyouokay wants to merge 2 commits intopayloadcms:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a regression in
@payloadcms/plugin-cloud-storagewhere create-time uploads with crop edits could upload to S3 successfully but fail to persist the resulting document metadata.Problem
When an image is uploaded during initial document creation with crop edits applied, the cloud storage
afterChangehook performs a nestedpayload.updateto persist returned upload metadata such asurl.That nested local API call was inheriting the original request's
uploadEditsquery state. Core upload handling then interpreted the metadata-only update as another crop/reupload operation. On initial create, the document did not yet have a usable persisted remote URL for that reprocessing path, so the metadata update failed and the server logged:Failed to persist upload data for collection <slug> document <id>This did not affect uploads without crop edits, or crop operations performed after the document had already been saved.
Regression likely introduced by #15570.
Solution
req.query.uploadEditsbefore the internal metadata persistencepayload.updateuploadEditsvalue after the nested update completesurlis persistedTesting
test/plugin-cloud-storage/int.spec.tsfor the create-with-crop path.PAYLOAD_DATABASE=sqlite COREPACK_HOME=/tmp/corepack pnpm exec vitest --project int test/plugin-cloud-storage/int.spec.ts -t "should persist upload metadata after an initial create with crop edits"