nerves-hub / nerves_hub_web

Manage firmware updates for Nerves devices
https://nerves-hub.org/
Apache License 2.0
179 stars 72 forks source link

Uploading duplicate firmware gives unfriendly error message #1473

Open rraub opened 2 weeks ago

rraub commented 2 weeks ago

Describe the bug When uploading a firmware build that has already been uploaded successfully, you are given a generic "Unknown error uploading firmware. " error message rather than a more specific message saying its a duplicate. The logs show

To Reproduce Steps to reproduce the behavior:

  1. Go to the /firmware/upload page
  2. Click on the box to upload firmware
  3. Select a firmware build
  4. upload
  5. go back to the /firmware/upload page
  6. try and re upload the same firmware that you did in the previous step
  7. See error Unknown error uploading firmware.

Expected behavior A message saying this firmware has already been uploaded, so that I don't think there's something wrong with the firmware build.

Screenshots Screenshot 2024-08-27 at 9 00 10 AM

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Error logs observed:

16:00:59.167 [error] pid=<0.1763.0> mfa=NervesHub.Firmwares.create_firmware/3 Error while publishing firmware: #Ecto.Changeset<action: :insert, changes: %{size: 32461873, version: "1.xx", description: "xx", author: "xx", org_id: x, product_id: x, uuid: "x", platform: "x", architecture: "armx, delta_updatable: x, org_key_id: x, upload_metadata: %{"s3_key" => "firmware/x/x.fw"}}, errors: [uuid: {"has already been taken", [constraint: :unique, constraint_name: "firmwares_product_id_uuid_index"]}], data: #NervesHub.Firmwares.Firmware<>, valid?: false>
joshk commented 2 weeks ago

Thanks for reporting this bug.

I'll work on a test for this and see if we can roll out a fix soon.