# "Failed to optimize image" error from discourse-topic-previews-sidecar

**URL:** https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911
**Category:** Support
**Created:** [July 30, 2026, 12:27pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911 "2026-07-30T12:27:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Takiro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/takiro/32/572426_2.png) [@Takiro](https://meta.discourse.org/u/Takiro)
#### Post date: [July 30, 2026, 12:27pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/1 "2026-07-30T12:27:44Z")

</div>

I updated to Discourse version v2026.8.0-latest a few days ago. Some user’s avatars have turned to a default image (not the letter avatar). Trying to upload a new image does nothing. The preview shows the image but upon saving it reverts back to the default image. It doesn’t matter if the user does it or an admin. The interface shows no error message.

First I tried refreshing avatars with rake, that did nothing. I then checked the logs and looked if something shows when I try to change the avatar image, i found the following log message:

> Failed to optimize image: unknown reason upload\_id: location: {raise\_on\_error: true, quality: 90, upload\_id: 235861} error\_message: no implicit conversion of Hash into String instructions: [“convert”, “png:/var/www/discourse/public/uploads/default/original/3X/2/c/2c620efd4ee10548884a11b7237d5aa9135817b1.png[0]”, “-quality”, “90”, “-auto-orient”, “-gravity”, “center”, “-background”, “transparent”, “-thumbnail”, “24x24^”, “-extent”, “24x24”, “-interpolate”, “catrom”, “-unsharp”, “2x0.5+0.7+0”, “-interlace”, “none”, “-profile”, “/var/www/discourse/vendor/data/RT\_sRGB.icm”, “png:/tmp/discourse-thumbnail20260730-360984-9yk3a1.png”]
> 
> Sent file /var/www/discourse/public/images/avatar.png (0.3ms)

So I guess there is a type mismatch in the code that handles image optimization.

Funny thing is, I also can’t upload an avatar on this forum too, suspecting that something similar is happening here too. At least here I get an error message about that “something went wrong”.

Any idea how I can resolve this issue, or is there nothing I can do other than waiting for a fix?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 30, 2026, 12:44pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/4 "2026-07-30T12:44:51Z")

</div>

Please can you share the full backtrace for that log? You can find that by visiting `/logs`, selecting it, and then choosing the ‘backtrace’ tab at the bottom.

---

<div class="post-metadata">

### Author: ![Takiro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/takiro/32/572426_2.png) [@Takiro](https://meta.discourse.org/u/Takiro)
#### Post date: [July 30, 2026, 12:53pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/5 "2026-07-30T12:53:10Z")

</div>

Of course, here it is.

```plaintext
Message (5 copies reported)

Failed to optimize image: unknown reason

Backtrace

/var/www/discourse/lib/discourse.rb:1115:in 'block in Discourse.warn'
/var/www/discourse/lib/discourse.rb:1109:in 'Array#each'
/var/www/discourse/lib/discourse.rb:1109:in 'Discourse.warn'
/var/www/discourse/app/models/optimized_image.rb:362:in 'OptimizedImage.convert_with'
/var/www/discourse/plugins/discourse-topic-previews-sidecar/lib/topic_previews/optimized_image_extension.rb:25:in 'TopicPreviews::OptimizedImageExtension#optimize'
/var/www/discourse/app/models/optimized_image.rb:317:in 'OptimizedImage.resize'
/var/www/discourse/lib/upload_creator.rb:583:in 'UploadCreator#crop!'
/var/www/discourse/lib/upload_creator.rb:115:in 'block in UploadCreator#create_for'
/var/www/discourse/lib/distributed_mutex.rb:53:in 'block in DistributedMutex#synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in 'Thread::Mutex#synchronize'
/var/www/discourse/lib/distributed_mutex.rb:49:in 'DistributedMutex#synchronize'
/var/www/discourse/lib/distributed_mutex.rb:34:in 'DistributedMutex.synchronize'
/var/www/discourse/lib/upload_creator.rb:102:in 'UploadCreator#create_for'
/var/www/discourse/app/models/user_avatar.rb:133:in 'UserAvatar.import_url_for_user'
/var/www/discourse/app/jobs/regular/download_avatar_from_url.rb:17:in 'Jobs::DownloadAvatarFromUrl#execute'
/var/www/discourse/app/jobs/base.rb:313:in 'block (2 levels) in Jobs::Base#perform'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in 'RailsMultisite::ConnectionManagement::NullInstance#with_connection'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/rails_multisite-7.0.0/lib/rails_multisite/connection_management.rb:17:in 'RailsMultisite::ConnectionManagement.with_connection'
/var/www/discourse/app/jobs/base.rb:300:in 'block in Jobs::Base#perform'
/var/www/discourse/app/jobs/base.rb:297:in 'Array#each'
/var/www/discourse/app/jobs/base.rb:297:in 'Jobs::Base#perform'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:220:in 'Sidekiq::Processor#execute_job'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:185:in 'block (4 levels) in Sidekiq::Processor#process'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:180:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:183:in 'block in Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/lib/sidekiq/suppress_user_email_errors.rb:6:in 'Sidekiq::SuppressUserEmailErrors#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:182:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:183:in 'block in Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/lib/sidekiq/discourse_event.rb:6:in 'Sidekiq::DiscourseEvent#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:182:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:183:in 'block in Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/lib/sidekiq/pausable.rb:131:in 'Sidekiq::Pausable#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:182:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:183:in 'block in Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/job/interrupt_handler.rb:9:in 'Sidekiq::Job::InterruptHandler#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:182:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:183:in 'block in Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/metrics/tracking.rb:26:in 'Sidekiq::Metrics::ExecutionTracker#track'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/metrics/tracking.rb:134:in 'Sidekiq::Metrics::Middleware#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:182:in 'Sidekiq::Middleware::Chain#traverse'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/middleware/chain.rb:173:in 'Sidekiq::Middleware::Chain#invoke'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:184:in 'block (3 levels) in Sidekiq::Processor#process'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:145:in 'block (6 levels) in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/job_retry.rb:118:in 'Sidekiq::JobRetry#local'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:144:in 'block (5 levels) in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/config.rb:39:in 'block in <class:Config>'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:139:in 'block (4 levels) in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:281:in 'Sidekiq::Processor#stats'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:134:in 'block (3 levels) in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/job_logger.rb:15:in 'Sidekiq::JobLogger#call'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:133:in 'block (2 levels) in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/job_retry.rb:85:in 'Sidekiq::JobRetry#global'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:132:in 'block in Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/job_logger.rb:40:in 'Sidekiq::JobLogger#prepare'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:131:in 'Sidekiq::Processor#dispatch'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:183:in 'block (2 levels) in Sidekiq::Processor#process'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:182:in 'Thread.handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:182:in 'block in Sidekiq::Processor#process'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:181:in 'Thread.handle_interrupt'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:181:in 'Sidekiq::Processor#process'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:86:in 'Sidekiq::Processor#process_one'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/processor.rb:76:in 'Sidekiq::Processor#run'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/component.rb:10:in 'Sidekiq::Component#watchdog'
/var/www/discourse/vendor/bundle/ruby/3.4.0/gems/sidekiq-7.3.10/lib/sidekiq/component.rb:19:in 'block in Sidekiq::Component#safe_thread'

```

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 30, 2026, 12:56pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/7 "2026-07-30T12:56:03Z")

</div>

> [@Takiro](#):
>
> ```plaintext
> /var/www/discourse/plugins/discourse-topic-previews-sidecar/lib/topic_previews/optimized_image_extension.rb:25:in 'TopicPreviews::OptimizedImageExtension#optimize'
> 
> ```

Looks like it’s the d-topic-previews-sidecar plugin. I’ll take a look and send them a PR for the core change.

> [@Takiro](#):
>
> Funny thing is, I also can’t upload an avatar on this forum too, suspecting that something similar is happening here too. At least here I get an error message about that “something went wrong”.

That’s surprising. We don’t have that plugin installed here, and avatar uploads seem to work for me. Could you try one more time? If you get an error, a screenshot would be great!

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [July 30, 2026, 1:01pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/8 "2026-07-30T13:01:59Z")

</div>

> [@david](#):
>
> Looks like it’s the d-topic-previews-sidecar plugin. I’ll take a look and send them a PR for the core change.

Ah, looks like this plugin is archived and no longer supported ([readme](https://github.com/merefield/discourse-topic-previews-sidecar)). You should remove it from your `app.yml` and run `./launcher rebuild app`.

---

<div class="post-metadata">

### Author: ![Takiro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/takiro/32/572426_2.png) [@Takiro](https://meta.discourse.org/u/Takiro)
#### Post date: [July 30, 2026, 1:13pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/9 "2026-07-30T13:13:06Z")

</div>

Yes I replaced the original plugin with the legacy package after the original repo was completely removed and not accessible anymore. i try to remove it and see if that makes a difference.

Here is the error message that pops up, when I try to upload an avatar here

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/e/1/9e1309806a3a6b73db29685201bd36f386ccae96.png)

But it works now, must have been an issue on my end.

Anyway, I report back after disabling the plugin.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [July 30, 2026, 1:26pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/10 "2026-07-30T13:26:22Z")

</div>

> [@Takiro](#):
>
> At least here I get an error message about that “something went wrong

I got this error after opening a topic half an hour ago. I don’t have repro steps.

 ![Screenshot_20260730_145426_Chrome](https://global.discourse-cdn.com/meta/original/4X/3/9/7/397bd4a5bb5f2801a0d73b1bef7c2974856426e8.jpeg)

---

<div class="post-metadata">

### Author: ![Takiro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/takiro/32/572426_2.png) [@Takiro](https://meta.discourse.org/u/Takiro)
#### Post date: [July 30, 2026, 1:38pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/11 "2026-07-30T13:38:26Z")

</div>

I removed the plugin and everything seems to be working fine again. Thanks for the help and sorry for bothering.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [August 29, 2026, 1:38pm UTC](https://meta.discourse.org/t/failed-to-optimize-image-error-from-discourse-topic-previews-sidecar/408911/12 "2026-08-29T13:38:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
