Repository navigation
fix(plugin-cloud-storage): should persist external data returned by storage providers - #15188
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
|
🚀 This is included in version v3.71.0 |
|
@rubixvi that does seems like a bug that would be caused by this PR, however when I test I cannot reproduce this at all. Could you share a basic repo that demonstrates this behavior? Are you using s3? Any changes to your upload config? |
|
@JessRynkar I'm running into this same issue, but I don't think it's related to your changes - though I think your changes did introduce a recursion bug. Steps to Reproduce
Result:
What I think the flow is:
I'm only about a week into using Payload so I'm not super familiar with how things are pieced together - hope this helps though! Here is a gif showing the issue: I added logging to check the hook call count. You can see the recursive updates below: Click to view log output[17:41:36] INFO: ---- DROPPING DATABASE ----
[17:41:36] INFO: ---- DROPPED DATABASE ----
[17:41:37] INFO: Using plugin-cloud-storage adapter: s3
GET /api/access 200 in 8.5s (compile: 7.8s, render: 777ms)
GET /admin 200 in 10.7s (compile: 9.1s, render: 1635ms)
GET /admin 200 in 12.1s (compile: 10.4s, render: 1640ms)
GET /api/users/me 200 in 22ms (compile: 9ms, render: 12ms)
GET /api/payload-preferences/nav 200 in 18ms (compile: 3ms, render: 14ms)
GET /admin/collections/media 200 in 126ms (compile: 14ms, render: 113ms)
GET /admin/collections/media/create 200 in 70ms (compile: 3ms, render: 67ms)
GET /api/payload-preferences/collection-media 200 in 12ms (compile: 4ms, render: 8ms)
POST /api/payload-preferences/collection-media 200 in 17ms (compile: 2ms, render: 15ms)
GET /api/payload-preferences/undefined 200 in 12ms (compile: 4ms, render: 9ms)
POST /admin/collections/media/create 200 in 17ms (compile: 4ms, render: 13ms)
└─ ƒ <inline action>({"args":{"collectionSlug":"media","docPermissions":"[Object]","docPreferences":null,"...":"8 items not stringified"},"name":"form-state"}) in 6ms app/(payload)/layout.tsx
-------------- (0) create DSC_1101-Enhanced-NR.jpg with 3 files --------------
(0) Context: {}
(0) Uploading 3 files [
{
buffer: <Buffer >,
clientUploadContext: undefined,
filename: 'DSC_1101-Enhanced-NR.jpg',
filesize: 2811091,
mimeType: 'image/jpeg',
tempFilePath: '/Users/synergy/github.com/open-source/payload/Users/synergy/github.com/open-source/payload/tmp/tmp-1-1769478189616'
},
{
buffer: <Buffer ff d8 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c 10 17 14 18 18 17 14 16 16 1a 1d 25 1f 1a 1b 23 1c 16 ... 16399 more bytes>,
filename: 'DSC_1101-Enhanced-NR-400x400.jpg',
filesize: 16449,
mimeType: 'image/jpeg'
},
{
buffer: <Buffer ff d8 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c 10 17 14 18 18 17 14 16 16 1a 1d 25 1f 1a 1b 23 1c 16 ... 33017 more bytes>,
filename: 'DSC_1101-Enhanced-NR-900x450.jpg',
filesize: 33067,
mimeType: 'image/jpeg'
}
]
(0) Persisting Metadata for 6978182dd07ba9999646665b with upload results: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:09.695Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 7009,
width: 200,
height: 200,
focalX: 50,
focalY: 50,
sizes: {
square: {
url: '/api/media/file/DSC_1101-Enhanced-NR-400x400.jpg',
width: 400,
height: 400,
mimeType: 'image/jpeg',
filesize: 16449,
filename: 'DSC_1101-Enhanced-NR-400x400.jpg'
},
sixteenByNineMedium: {
url: '/api/media/file/DSC_1101-Enhanced-NR-900x450.jpg',
width: 900,
height: 450,
mimeType: 'image/jpeg',
filesize: 33067,
filename: 'DSC_1101-Enhanced-NR-900x450.jpg'
}
},
id: '6978182dd07ba9999646665b',
thumbnailURL: null
}
(0) Persisted Metadata for 6978182dd07ba9999646665b
(0) Returning
POST /api/media?depth=0&fallback-locale=null 201 in 137ms (compile: 4ms, render: 133ms)
GET /api/media/file/DSC_1101-Enhanced-NR.jpg 304 in 45ms (compile: 4ms, render: 41ms)
GET /admin/collections/media/6978182dd07ba9999646665b 200 in 133ms (compile: 2ms, render: 131ms)
GET /api/media/file/DSC_1101-Enhanced-NR.jpg?2026-01-27T01%3A43%3A09.729Z 200 in 22ms (compile: 2ms, render: 20ms)
GET /api/media/file/DSC_1101-Enhanced-NR.jpg 200 in 17ms (compile: 1391µs, render: 15ms)
-------------- (1) update DSC_1101-Enhanced-NR.jpg with 1 files --------------
(1) Context: {}
(1) Previous Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:09.729Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 7009,
width: 200,
height: 200,
focalX: 50,
focalY: 50,
sizes: {
square: {
url: '/api/media/file/DSC_1101-Enhanced-NR-400x400.jpg',
width: 400,
height: 400,
mimeType: 'image/jpeg',
filesize: 16449,
filename: 'DSC_1101-Enhanced-NR-400x400.jpg'
},
sixteenByNineMedium: {
url: '/api/media/file/DSC_1101-Enhanced-NR-900x450.jpg',
width: 900,
height: 450,
mimeType: 'image/jpeg',
filesize: 33067,
filename: 'DSC_1101-Enhanced-NR-900x450.jpg'
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(1) Updated Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.308Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6985,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(1) Deleting 3 files: [
'DSC_1101-Enhanced-NR.jpg',
'DSC_1101-Enhanced-NR-400x400.jpg',
'DSC_1101-Enhanced-NR-900x450.jpg'
]
(1) Uploading 1 files [
{
buffer: <Buffer ff d8 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c 10 17 14 18 18 17 14 16 16 1a 1d 25 1f 1a 1b 23 1c 16 ... 6935 more bytes>,
clientUploadContext: undefined,
filename: 'DSC_1101-Enhanced-NR.jpg',
filesize: 6985,
mimeType: 'image/jpeg',
tempFilePath: undefined
}
]
(1) Persisting Metadata for 6978182dd07ba9999646665b with upload results: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.308Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6985,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
GET /api/media/file/DSC_1101-Enhanced-NR.jpg 200 in 14ms (compile: 1428µs, render: 13ms)
-------------- (2) update DSC_1101-Enhanced-NR.jpg with 1 files --------------
(2) Context: { callCount: 1, settingMetadata: true }
(2) Previous Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.308Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6985,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(2) Updated Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.353Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6981,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(2) Deleting 3 files: [ 'DSC_1101-Enhanced-NR.jpg', null, null ]
(2) Uploading 1 files [
{
buffer: <Buffer ff d8 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c 10 17 14 18 18 17 14 16 16 1a 1d 25 1f 1a 1b 23 1c 16 ... 6931 more bytes>,
clientUploadContext: undefined,
filename: 'DSC_1101-Enhanced-NR.jpg',
filesize: 6981,
mimeType: 'image/jpeg',
tempFilePath: undefined
}
]
(2) Persisting Metadata for 6978182dd07ba9999646665b with upload results: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.353Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6981,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
GET /api/media/file/DSC_1101-Enhanced-NR.jpg 200 in 17ms (compile: 1069µs, render: 16ms)
-------------- (3) update DSC_1101-Enhanced-NR.jpg with 1 files --------------
(3) Context: { callCount: 2, settingMetadata: true }
(3) Previous Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.353Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6981,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(3) Updated Doc: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.392Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6983,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
(3) Deleting 3 files: [ 'DSC_1101-Enhanced-NR.jpg', null, null ]
(3) Uploading 1 files [
{
buffer: <Buffer ff d8 ff db 00 43 00 06 04 05 06 05 04 06 06 05 06 07 07 06 08 0a 10 0a 0a 09 09 0a 14 0e 0f 0c 10 17 14 18 18 17 14 16 16 1a 1d 25 1f 1a 1b 23 1c 16 ... 6933 more bytes>,
clientUploadContext: undefined,
filename: 'DSC_1101-Enhanced-NR.jpg',
filesize: 6983,
mimeType: 'image/jpeg',
tempFilePath: undefined
}
]
(3) Persisting Metadata for 6978182dd07ba9999646665b with upload results: {
createdAt: '2026-01-27T01:43:09.694Z',
updatedAt: '2026-01-27T01:43:25.392Z',
url: '/api/media/file/DSC_1101-Enhanced-NR.jpg',
filename: 'DSC_1101-Enhanced-NR.jpg',
mimeType: 'image/jpeg',
filesize: 6983,
width: 200,
height: 200,
focalX: 100,
focalY: 51,
sizes: {
square: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
},
sixteenByNineMedium: {
url: null,
width: null,
height: null,
mimeType: null,
filesize: null,
filename: null
}
},
thumbnailURL: null,
id: '6978182dd07ba9999646665b'
}
GET /api/media/file/DSC_1101-Enhanced-NR.jpg 200 in 17ms (compile: 1049µs, render: 16ms)
[17:43:25] ERROR: (4) Recursion level reached, returning doc
(3) Persisted Metadata for 6978182dd07ba9999646665b
(3) Returning
(2) Persisted Metadata for 6978182dd07ba9999646665b
(2) Returning
(1) Persisted Metadata for 6978182dd07ba9999646665b
(1) Returning
PATCH /api/media/6978182dd07ba9999646665b?depth=0&fallback-locale=null&uploadEdits%5Bcrop%5D%5Bheight%5D=100&uploadEdits%5Bcrop%5D%5Bunit%5D=%25&uploadEdits%5Bcrop%5D%5Bwidth%5D=100&uploadEdits%5Bcrop%5D%5Bx%5D=0&uploadEdits%5Bcrop%5D%5By%5D=0&uploadEdits%5BfocalPoint%5D%5Bx%5D=100&uploadEdits%5BfocalPoint%5D%5By%5D=51&uploadEdits%5BheightInPixels%5D=200&uploadEdits%5BwidthInPixels%5D=200 200 in 187ms (compile: 8ms, render: 178ms)
POST /api/media/access/6978182dd07ba9999646665b 200 in 6ms (compile: 1170µs, render: 5ms)
POST /api/media/access/6978182dd07ba9999646665b 200 in 7ms (compile: 2ms, render: 5ms)
GET /api/media/file/DSC_1101-Enhanced-NR.jpg?2026-01-27T01%3A43%3A25.308Z 200 in 20ms (compile: 1380µs, render: 19ms)
GET /api/payload-preferences/collection-media-6978182dd07ba9999646665b 200 in 12ms (compile: 3ms, render: 9ms)
POST /admin/collections/media/6978182dd07ba9999646665b 200 in 15ms (compile: 4ms, render: 10ms) |
|
Hi @FledgeMike, thank you for the all info there! I'm looking into this now. Related issue. |
|
@FledgeMike just an update, that issue has been resolved in this PR: #15188 |
|
@JessRynkar Thanks for the follow up! This definitely fixed the recursion issue! However, I'm still seeing the issue where the sizes are being nuked after adjjusting the focal point I've created a draft PR #15444 with a test added to the e2e suite to hopefully better illustrate the issue |



What
Fixes issue where storage metadata (object keys, timestamps, custom IDs, etc.) from external providers (s3, azure, etc) is no longer persisted back to the main doc. This issue was introduced in PR #14988 when the external upload process was moved from the
beforeChangetoafterChangehook.Why
Without automatically persisting metadata from external storage, users have to manually update the doc themselves. This restores backward compatibility for existing custom storage adapters.
Where
Added automatic data capture/persistence in
packages/plugin-cloud-storage/src/hooks/afterChangeTesting
Added to test suite
test/plugin-cloud-storage