-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupted Active Storage attachments #4017
Comments
I had another issue uploading a not supported file type (
Login into the admin and upload a |
I was able recreate this issue by:
The issue appears to be with ActiveStorage as it queues the upload of the image after the objects are created and when it fails to upload, it does not purge the existence of the image and the created objects. The image and attachment persist with an ActiveStorage record still found in the database. Subsequent calls for the object expect a file to be returned from the server and solidus currently does not handle the exception for missing file. Initial remedy provided by the original poster was an exception handle in ActiveStorageAttachment that appended a revised url method:
This solution does not rectify the creation of an image or attachment when there is a failure to upload, and only bypasses an exception if the the image cannot be found on third part storage. Ideally we would want to prevent the object from ever being created should the image fail to upload. This might be difficult to accomplish based on the way the the objects and jobs are created. Therefore, we could also potentially run a validation ActiveStorageAdapter or implement a post processing job to clean up Images with failed uploads. |
Stack trace for further investigation |
Hey guys!
I have an issue using
ActiveStorageAttachment
for product images.I'm using an S3-compatible service for storing attachments, and it's working ok. But if the service returns an error (it is down at the moment the user attempts to upload an image or there's a permission error, etc), a product image record and ActiveStorage blob record are created anyway despite the image processing error. So it produces a corrupted state of the system. And then any code which calls
.url(style)
on this image gets anActiveStorage::FileNotFoundError
exception, because it tries to run image processing to create the requested image variant, but it can't find the original image because its upload never finished (it happens on any page which needs to display the image).Ideally, I would like it to be "all or nothing", so the database records get committed only after the storage service responded with a success.
Is it a problem of how ActiveStorage works itself or is it a Solidus wrapper's one? How do I prevent the situation when one failed image upload breaks down the whole store (you can't even delete the corrupted image, because the admin product page is also broken)?
Originally posted by @ok32 in #3986
The text was updated successfully, but these errors were encountered: