S3: Failed to optimize image: no images defined

AI-generated summary

A user, JulesW, reports a bug in Discourse v2.3.0.beta9 where image optimization fails with an error indicating that S3 images cannot be accessed, despite successful uploads to the S3 bucket. The issue is traced to a missing URL scheme in the image path, suggesting a misconfiguration in S3 integration. The error occurs during avatar thumbnail creation, with the system attempting to access the image via a local path instead of S3. Gerhard suggests updating to the latest version, which resolves the issue. Jomaxro clarifies that rolling back to an older version is not possible and advises against using the stable branch for production due to its infrequent updates and lack of guaranteed bug fixes, recommending the tests-passed branch instead julesw.

Version v2.3.0.beta9 +665. Error summary is:


hostname	localhost-app
process_id	162
application_version	b114bcd2949fee2925eab8faf34cd02d64eb3ab1
job	Jobs::CreateAvatarThumbnails
db	default
location	/tmp/discourse-thumbnail20190529-162-lvynlw.gif
error_message	/var/www/discourse/app/models/optimized_image.rb:338:in `convert_with': convert: unable to open image '//my-s3-bucket.s3.dualstack.us-west-1.amazonaws.com/original/1X/e806e13d29b85e6c7c12d59f00ce73bc1948034f.gif': No such file or directory @ error/blob.c/OpenBlob/3497. convert: no images defined `gif:/tmp/discourse-thumbnail20190529-162-lvynlw.gif' @ error/convert.c/ConvertImageCommand/3300.

I’m rehearsing a deploy process for a new discourse site which has been running in dev for a while now (with no problems re: S3 image hosting), and I’m now having some trouble with S3 image hosting.

I can reproduce it with a fresh install as per the docs. Then I add my S3 credentials etc as per these docs.

To test, I then set a custom avatar of the admin user.

The avatar is successfully uploaded to S3 (and can be seen in the original folder within the bucket). But the thumbnails etc fail to get created as per that error message.

I’m at a loss to what’s happening here. Any ideas?

Can someone tell me how I can force an install of build 424 (which was the working version in my dev environment)?

Only differences I’ve spotted so far are the imagemagick version:

Version: ImageMagick 7.0.8-42 Q16 x86_64 2019-05-05 https://imagemagick.org
vs
Version: ImageMagick 7.0.8-42 Q16 x86_64 2019-04-29 https://imagemagick.org

Regarding the error I’m seeing; this is the bit that sticks out to me:

convert: unable to open image '//my-s3-bucket.s3.dualstack.us-west-1.amazonaws.com/original/1X/e806e13d29b85e6c7c12d59f00ce73bc1948034f.gif': No such file or directory

Should there be a URL scheme in front of the //? Is this trying to access the local filesystem?

Can you update to latest? It should be fixed by Revert changes to `FileStore::S3Store#path_for` in f0620e7118a76a1fae… · discourse/discourse@a3938f9 · GitHub

4 Likes

Yep that fixed it.

How can I rollback to an older version? Is there a specific stable branch I should be using in production instead of the bleeding edge?

It is not possible to roll back versions. If you want to track a branch other than tests-passed, you can, but we generally do not recommend it. See Which branch of Discourse is used internally? for discussion on Discourse release branches. A note on stable, it is only “stable” in that we do not update it very often. While we make every attempt to release bug free software, we don’t guarantee stable to be bug free. Think of stable more as “I know what bugs I have and I’m stuck with them” vs tests-passed which has “unknown bugs appear, but get fixed quickly”.

2 Likes