openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.11k stars 719 forks source link

Uploaded files can be corrupted after upload and we raise an error on every view #9302

Open mkllnk opened 2 years ago

mkllnk commented 2 years ago

Description

File storage seems imperfect. A file can become corrupted after it has been uploaded successfully. Then Active Storage can't resize it to display on different pages. We don't handle this error very well.

This is most commonly seen on the /admin/products page and can easily be corrected by uploaded the file again. But some people also experienced it in the order cycle edit screen. The image would also appear broken in the shop and the order confirmation.

Technically, each time someone tries to view the image, the app downloads it from (cloud) storage and then realises that it's broken. This seems very inefficient.

Expected Behavior

Actual Behaviour

Steps to Reproduce

  1. Upload a product image.
  2. Find the image name in the database: ActiveStorage::Blob.last.key
  3. Find the image on the storage and replace it with another image.
  4. View the product listing again.

Animated Gif/Screenshot

Workaround

Upload the image again.

Severity

bug-s1: a critical feature is broken: checkout, payments, signup, login bug-s2: a non-critical feature is broken, no workaround bug-s3: a feature is broken but there is a workaround bug-s4: it's annoying, but you can use it bug-s5: we can live with it, only a few users impacted

https://github.com/openfoodfoundation/openfoodnetwork/wiki/Bug-severity

Your Environment

Possible Fix

The error needs to be caught in a Rails controller. That may require a monkey-patch. Or maybe Rails will improve Active Storage? :shrug:

Error in OpenFoodNetwork Aus

ActiveStorage::IntegrityError in active_storage/representations/redirect#show ActiveStorage::IntegrityError

View on Bugsnag

Stacktrace

lib/session_cookie_upgrader.rb:19 - call

View full stacktrace

Created by Maikel via Bugsnag

mkllnk commented 2 years ago

Not that important.

Comment added in Bugsnag by Maikel ActiveStorage::IntegrityError in active_storage/representations/redirect#show

mkllnk commented 2 years ago

An error linked to this issue has been reopened in Bugsnag ActiveStorage::IntegrityError in active_storage/representations/redirect#show

filipefurtad0 commented 1 year ago

Several occurrences recently, triggered by two (or more) shops/corrupt pics, on the shopfront:

mkllnk commented 4 months ago

This issue has been linked to an error in Bugsnag fr_prod: RuntimeError in enterprises#shop

dacook commented 4 months ago

This has been occurring on the fr_prod shopfront, with 25 events since 4th Jun, and 74 all-time events.

RuntimeError enterprises#shop
Enterprise #279 promo_image error: ActiveStorage::IntegrityError