Repository navigation
Closed
Labels
Description
Problem
After updating to Payload 3.46.0+ (also broken in 3.47.0) I cannot update the doc in my media upload collection. Trying to do so results in the console printing out the following error:
[23:13:47] ERROR: There was a problem while uploading the file. fetch failedReproduction
I have a publicly readable media collection running with @payloadcms/storage-s3 and minio, with some custom hooks which ensure the media is renamed upon upload to have a unique name, as per the official docs example.
After creating a media document I am forbidden from updating the document in any way. This includes changing other fields such as alt, of type: "text".
Here is my media.ts file:
import type { CollectionConfig } from "payload";
import { getUniqueFilename } from "~/lib/utils/media";
export const Media: CollectionConfig = {
slug: "media",
admin: {
useAsTitle: "name",
},
access: {
read: () => true,
},
fields: [
{
name: "name",
type: "text",
},
{
name: "alt",
type: "textarea",
required: true,
},
],
upload: {
// disabling this results in a different error something along the lines of "Blocked unsafe attempt"
skipSafeFetch: true,
},
hooks: {
beforeOperation: [
async ({ req, operation }) => {
// generate a unique filename for the uploaded file
if ((operation === "create" || operation === "update") && req.file) {
const newFilename = getUniqueFilename(req.file.mimetype);
req.file.name = newFilename;
}
},
],
},
};And my s3Storage configuration in payload.config.ts:
s3Storage({
bucket: "media",
collections: {
media: true,
},
config: {
credentials: {
accessKeyId: env.MINIO_ROOT_USER,
secretAccessKey: env.MINIO_ROOT_PASSWORD,
},
region: "region",
endpoint: env.MINIO_URL,
forcePathStyle: true,
},
}),Additional info
- Cannot update any field after adding a media (e.g. name, alt...)
- Started happening after
3.46.0, also verified that is still an issue in3.47.0 - Only happens in production
- Production is a self-hosted standalone Next.js build running in a docker container
- Setting
skipSafeFetch: falseresults in an error. Something along the lines of - In the versions prior (e.g.
3.45.0) settingskipSafeFetch: truefixes the issue
Environment Info
payload: 3.47.0
next: 15.3.5
@payloadcms/db-postgres: 3.47.0
@payloadcms/email-nodemailer: 3.47.0
@payloadcms/graphql: 3.47.0
@payloadcms/live-preview: 3.47.0
@payloadcms/live-preview-react: 3.47.0
@payloadcms/next/utilities: 3.47.0
@payloadcms/payload-cloud: 3.47.0
@payloadcms/plugin-cloud-storage: 3.47.0
@payloadcms/plugin-multi-tenant: 3.47.0
@payloadcms/richtext-lexical: 3.47.0
@payloadcms/storage-s3: 3.47.0
@payloadcms/translations: 3.47.0
@payloadcms/ui/shared: 3.47.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32689
Available CPU cores: 16
Activity
github-actions commentedon Jul 11, 2025
Please add a reproduction in order for us to be able to investigate.
Depending on the quality of reproduction steps, this issue may be closed if no reproduction is provided.
Why was this issue marked with the
invalid-reproductionlabel?To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository created with
create-payload-app@latest -t blankor a forked/branched version of this repository with tests added (more info in the reproduction-guide).To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.
Please test your reproduction against the latest version of Payload to make sure your issue has not already been fixed.
I added a link, why was it still marked?
Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.
Useful Resources
[-]Cannot rename media in production after 3.46.0+[/-][+]Cannot UPDATE media docs in production after 3.46.0+[/+][-]Cannot UPDATE media docs in production after 3.46.0+[/-][+]Cannot update media docs in production after 3.46.0+[/+][-]Cannot update media docs in production after 3.46.0+[/-][+]Cannot update media doc in production after 3.46.0+[/+]mikkelwf commentedon Jul 13, 2025
Try adding
skipSafeFetch: trueto the upload configsimovicaleksa commentedon Jul 13, 2025
As you can see from the code example of my media collection config that's what the issue is about. In prior versions to
3.46.0that fixed the issue, but now I get an error regardlessskipSafeFetchvalue.For example with
skipSafeFetch: trueI am getting:[23:13:47] ERROR: There was a problem while uploading the file. fetch failedAnd with
skipSafeFetch: falseI get:My guess is it's got likely something to do with: #13018.
Edit:
Here is an image describing my setup on a higher level. Caddy acts as a reverse proxy between User and App. App and MinIO are connected to each other via HTTP. This connection is secure even if it's HTTP since it's internal. This might be what's causing the
"Blocked unsafe attempt"issues, but it does not explain why I can upload a media in the first place.mikkelwf commentedon Jul 14, 2025
Sorry, didn't see you've applied skipSafeFetch already..
I got the same error and it started working when I applied
skipSafeFetch: truemikenicklas commentedon Jul 19, 2025
FWIW, I was running into this issue as well. I had the standard
Mediacollection as defined by the payload installation template I used. We're using S3 uploads with this config:Payload versions:
I was unable to update the
alttag of aMediarecord once it was published. However setting theskipSafeFetchdid seem to resolve that for me ✅simovicaleksa commentedon Jul 22, 2025
@mikenicklas, @kendelljoseph It was like this for me as well before updating to payload
3.46.0+.skipSafeFetch: trueused to fix the issue until I updated payload to the latest version. The update/change that probably introduced this bug is #13018.I suspect that the reason is because I am running my app container as a part of an
internalnetwork in docker (behind a reverse proxy), thus it is not able to resolve to adnsdirectly. This causes the node.jspromises/dnsto throw an error, canceling the UPDATE transaction onmediadocument.This would also explain why it only happens in production, as during development my app has access to a
dns.I feel like this should be considered as a bug on payload's side since it does not allow the user to be fully disable the
safeFetch/dns-lookupcheck.fix: filter `payload-` cookies in `getExternalFile` only if the URL i…
r1tsuu commentedon Aug 21, 2025
This issue was fixed here #13475
github-actions commentedon Aug 29, 2025
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.