BeaconCMS / BeaconCMS/beacon

Do not swallow Media upload errors

Open
#629 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Elixir
Stars
1.3k
Forks
134
PR merge metrics
No merged PRs in 30d

Description

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, 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, 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.

Contributor guide

Open the contributing guide

Research direction

Start at Beacon.LiveAdmin.MediaLibraryLive.UploadFormComponent and the Beacon.MediaLibrary.upload call shown in the report, then reproduce an upload failure and trace its handling in the live admin screens. Done means an upload error is not swallowed and the user receives explicit feedback about the failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.