ActiveStorage issue; missing images

Hi everyone, I am the author of a website for my local soccer club. I performed a release the other day and all of the sudden all items (images and pdfs) that I’ve stored with ActiveStorage have stopped showing. The log shows

I, [2021-04-08T01:27:22.262139 #1287]  INFO -- : [7b26516a-a6ad-445d-855a-23108517e41d] Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDRG9JYTJWNVNTSWRXWEpDZUdsdGR6TktNbUp4VUZOQ2ExWkVTRkpOY1VGT0Jqb0dSVlE2RUdScGMzQnZjMmwwYVc5dVNTSlJhVzVzYVc1bE95Qm1hV3hsYm1GdFpUMGljbVZtWlhKbFpWOWpiR0Z6YzJWekxuQnVaeUk3SUdacGJHVnVZVzFsS2oxVlZFWXRPQ2NuY21WbVpYSmxaVjlqYkdGemMyVnpMbkJ1WndZN0JsUTZFV052Ym5SbGJuUmZkSGx3WlVraURtbHRZV2RsTDNCdVp3WTdCbFE9IiwiZXhwIjoiMjAyMS0wNC0wOFQwMTozMjoxNy4zNDBaIiwicHVyIjoiYmxvYl9rZXkifX0=--3768f57bfcae1a0e7bc40f1a6fcc47d88c11b73c/referee_classes.png?content_type=image%2Fpng&disposition=inline%3B+filename%3D%22referee_classes.png%22%3B+filename%2A%3DUTF-8%27%27referee_classes.png" for 167.248.190.42 at 2021-04-08 01:27:22 +0000
I, [2021-04-08T01:27:22.262794 #1287]  INFO -- : [7b26516a-a6ad-445d-855a-23108517e41d] Processing by ActiveStorage::DiskController#show as PNG
I, [2021-04-08T01:27:22.262845 #1287]  INFO -- : [7b26516a-a6ad-445d-855a-23108517e41d]   Parameters: {"content_type"=>"image/png", "disposition"=>"inline; filename=\"referee_classes.png\"; filename*=UTF-8''referee_classes.png", "encoded_key"=>"[FILTERED]", "filename"=>"referee_classes"}
I, [2021-04-08T01:27:22.263529 #1287]  INFO -- : [7b26516a-a6ad-445d-855a-23108517e41d] Completed 200 OK in 1ms (ActiveRecord: 0.0ms)

However the image does not show up. None of the images show up. This has me completely stumped as there are no errors or warnings and this only happens in my production environment. The images are there on the disk as they always have been.

Can anyone give me direction on how to diagnose and fix this?

thanks,

Scott Director Hulmeville Soccer Club https://www.hulmevillesoccer.org

There are a lot of potential pitfalls between asking for an image and getting it displayed on the screen.

It looks as though the files are there and that ActiveStorage is finding them on your disk storage. As none of the images is visible it looks like a general problem.

Can you use your browser’s development tools?

They will let you look at the source code for the page and let you pinpoint the problem.

Short lesson: activate browser tool (Chrome - right click on/near where an image should be, and select inspect. Something very similar for Firefox).

You should see HTML and be able to find the tag for the image (<img src="...."/>). A bit of hovering/checking the styling and layout might help for some problems. If it can find the image it will probably show it for you.

[I had a problem a while back where all the image thumbnails had a height/width of 0/0].

If the HTML and styling looks good, you also have a Sources Tab, a Console tab and a Network tab which can report errors that are outside the Rails environment.

Production Environment What is different? Are you using a different storage service? Are you convinced the files are there? Does the storage service log look good?

Good luck

Anita,

Thank you so much for getting back to me. It’s local storage, as simple as I can keep it.

The network log shows 304. Images are coming back as “broken icons”.

The URL is being generated from

<%= image_tag url_for(image.image), class: “d-block w-100” %>

as it always has been. I’ve had this running smooth for years. None of that changed.

I’ve rebooted the VM, updated the system, etc.

I wasn’t aware of a “storage log” where is that?

Another symptom, the console cannot find any models.

2.6.2 :001 > Member.where(last_name: “Glass”) returns

Traceback (most recent call last):

1: from (irb):1

NameError (uninitialized constant Member)

I’m starting a project to migrate to Rails 7 in my “dev environment”.

The site is on life support at this point.

Thank you again!

Scott

Hi, First you said you said you performed an update, can you confirm that the images are visible after a rollback? What was released? Does it include a Rails update, new configuration?

Do you use a CDN? It makes me think of a caching issue, activestorage

From linking to files guide Generate a permanent URL for the blob that points to the application. Upon access, a redirect to the actual service endpoint is returned. This indirection decouples the service URL from the actual one, and allows, for example, mirroring attachments in different services for high-availability. The redirection has an HTTP expiration of 5 minutes

I’ve faced the issue that the permanent URL response was cached so after 5 minutes it requested an invalid URL, the worst was that it was not visible for me as my browser cached the images, but all new user had no images.

Can you check in your browser developer tool network request tab and check the requested URLs and headers properties.

Bonjour Jean-François,

Thanks for getting back to me. Rollback doesn’t seem to have any effect. I ended up just blowing all active storage up. Removed all attachment records from the tables, completely nuked storage.

Still nothing works, even with a “clean” subsystem.

Found an answer to my console issue at least. Somehow spring made it into the production environment. Running “spring stop” fixed that issue.

Scott