You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plugin-cloud-storage: since 3.90, files without ?prefix= return 500 when collection read access allows only static-file reads (getFilePrefix ignores isReadingStaticFile) #19008
Payload's own static-file check (uploads/checkFileAccess) passes isReadingStaticFile: true, so this worked through 3.89.
Since 3.90, @payloadcms/plugin-cloud-storage's getFilePrefix (packages/plugin-cloud-storage/src/utilities/getFilePrefix.ts, ~line 96) runs a second lookup before serving the object, when the serve path did not already load the doc (i.e. the URL has no ?prefix=):
That call goes through collection read access withoutisReadingStaticFile, so the rule above returns false, find throws Forbidden, and the file request fails with 500 for every anonymous caller.
Affected in practice:
every file URL in a collection without a prefix (the afterRead hook never appends ?prefix= there), e.g. media;
every file URL stored before 3.90 (no ?prefix=), e.g. URLs saved in rich text, JSON, emails;
next/image optimisation of those URLs (fetches anonymously → 400).
With ?prefix= it works, because checkFileAccess already loaded the doc and getFilePrefix returns early.
Reproduction Steps
s3Storage (no clientUploads, no disablePayloadAccessControl) on an upload collection with the read rule above.
Upload a file as an admin.
curl -i /api/<slug>/file/<filename> with no session (and no ?prefix=).
3.89: 200. 3.90–3.92: 500 (Forbidden: You are not allowed to perform this action. in the server log).
Expected
The prefix lookup should be treated as part of serving the static file — e.g. call the read access with isReadingStaticFile: true (the same way checkFileAccess does), or run the lookup with overrideAccess: true after checkFileAccess has already authorised the request.
Workaround
Return a match-nothing Where instead of false for non-staff document reads:
Mind if I take this? I'm thinking getFilePrefix should run the read access with isReadingStaticFile: true like checkFileAccess does, instead of a plain find that drops that flag. Will open a PR with a test.
Activity
cestercian commentedon Oct 23, 2026
Mind if I take this? I'm thinking getFilePrefix should run the read access with isReadingStaticFile: true like checkFileAccess does, instead of a plain find that drops that flag. Will open a PR with a test.