Skip to content

Do not swallow Media upload errors #629

@leandrocp

Description

@leandrocp

A bug in the upload logic might raise errors such as:

[debug] HANDLE EVENT "validate" in Beacon.LiveAdmin.PageLive
  Component: Beacon.LiveAdmin.MediaLibraryLive.UploadFormComponent
  Parameters: %{"_target" => ["asset"]}
[debug] Replied in 374µs
[info] JOINED lvu:0 in 745µs
  Parameters: %{"token" => "[redacted]"}
[debug] failed to call Beacon.MediaLibrary.upload(%Beacon.MediaLibrary.UploadMetadata{site: :my_site, config: %{processor: &Beacon.MediaLibrary.Processors.Image.process!/1, providers: [Beacon.MediaLibrary.Provider.Repo], validations: []}, allowed_media_accept_types: ["image/jpeg", "image/gif", "image/png", "image/webp", ".pdf"], path: "/tmp/plug-1730-HXLr/live_view_upload-1730156638-779982521169-1", name: "IMG_9166.jpg", media_type: "image/jpeg", size: 253356, output: nil, resource: #Ecto.Changeset<action: nil, changes: %{}, errors: [], data: #Beacon.MediaLibrary.Asset<>, valid?: true, ...>, extra: nil}) for site :my_site on node :nonode@nohost
[error] GenServer #PID<0.1757.0> terminating
** (Beacon.LiveAdmin.ClusterError) failed to call Beacon.MediaLibrary.upload(%Beacon.MediaLibrary.UploadMetadata{site: :my_site, config: %{processor: &Beacon.MediaLibrary.Processors.Image.process!/1, providers: [Beacon.MediaLibrary.Provider.Repo], validations: []}, allowed_media_accept_types: ["image/jpeg", "image/gif", "image/png", "image/webp", ".pdf"], path: "/tmp/plug-1730-HXLr/live_view_upload-1730156638-779982521169-1", name: "IMG_9166.jpg", media_type: "image/jpeg", size: 253356, output: nil, resource: #Ecto.Changeset<action: nil, changes: %{}, errors: [], data: #Beacon.MediaLibrary.Asset<>, valid?: true, ...>, extra: nil}) for site :my_site on node :nonode@nohost

Got:

  no function clause matching in Image.Error.exception/1

But as reported "the net result of this error is that the page reloads without showing success or failure, and the image is not listed. No error is reported to the user interface in the live admin screens" which should not be the behavior, we should be explicit that something out of ordinary happened and give some feedback to users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions