#17059·medusa

[Bug]: Product media edit continues after a failed upload and hides the server's error

Author: tolakangCreated Sep 28, 2026Updated Sep 29, 2026
Labelsgood first issuetype: bug

Package / version

@medusajs/dashboard 2.21.1 (Medusa 2.21.1, @medusajs/file-s3 provider)

What happens

In Products → a product → Media → Edit, when POST /admin/uploads fails (e.g. a custom middleware on that route rejects a file with 400 invalid_data and a clear message), the form:

  1. replaces the server's message with the generic products.media.failedToUpload, and
  2. continues: it calls sdk.admin.product.update with the failed file's entry still in images, but without a url.

The admin then shows "Invalid request: Field 'images, 5, url' is required", which tells the user nothing about the real cause.

Where

dist/product-media-*.mjs, the edit form's handleSubmit:

javascript
const { files: uploads } = await sdk.admin.upload
  .create({ files: filesToUpload.map((m) => m.file) })
  .catch(() => {
    form.setError("media", { type: "invalid_file", message: t("products.media.failedToUpload") })
    return { files: [] }
  })
// ... then media.map(...) sets url: uploaded[i]?.url (undefined) and the update is sent

For comparison, the create form (product-create-*.mjs) shows error.message in a toast, but also continues (it creates the product without the media).

Steps to reproduce

  1. Add a project middleware on POST /admin/uploads that calls next(new MedusaError(MedusaError.Types.INVALID_DATA, "SVG files are not allowed.")) for SVG files (or make the file provider throw).
  2. Edit a product's media, add an SVG next to the existing images, click Save.
  3. Result: "Field 'images, N, url' is required". Expected: the server's message, and no product update.

Expected

  • Stop the submit when the upload fails (don't call the product update), and
  • show the server's error message (error.message) instead of only the generic text.

Related

  • A way to restrict the file types the media dropzone accepts (it currently allows image/svg+xml), so shops that don't want SVG can refuse it before upload. Related but different: #14763 (closed), about a hard-coded upload size limit in the admin UI.