Some linked images not displaying/show as broken

I’m migrating a load of content, about 15k worth of news stories to Discourse via the API and these topics have links to images in. The images have just been uploaded to blob storage and are fully accessible publicly.

Most topics have the images shown correctly and get hotlink downloaded and uploaded into Discourse as you’d expect. Some though either do not get past the point of showing as links in the topic, or end up getting shown as broken images for some reason.

i.e.

Just staying as links:

Getting broken:

In the broken case, the topic shows as this when editing:

Config is:
Virgin Discourse install just for testing the migration
S3 storage of images

I’ve had no problems just creating posts as a user and uploading issues, it seems to only occur when I migrating posts via the API, i.e. in bulk and in quick succession (am using the skip_validations=true parameter). So far I’ve only migrated a maximum of 1,000 topics before clearing down and starting again.

Any ideas for what might be causing this? Or any tips on how to diagnose? All the Hotlink Sidekiq jobs seem to schedule and run as you’d expect.

rake posts:rebake doesn’t help

4 Likes

How about the rebuilt html option with the little admin wrench?

image

3 Likes

Your file has a double extension - .jpeg.jpg - is that true of all of the files which have been rejected?

Have any double-extension files been processed successfully?

4 Likes

Thanks Robert. This is working for the first few I’ve tried. It’s going back to square one, i.e. rendering the hotlinked image, and then downloading/uploading it.

I’ll have to see if this can be automated, though it doesn’t get to the root cause of why they’re failing to start with.

2 Likes

No, the double extension images are the minority and do not make up all of the failures. The Rebuild HTML option fixes these cases as well though.

2 Likes

That’s fantastic and congratulations, :partying_face: fortunately I learned that from other helpful people here when I’ve had similar issues and I’m happy I could pass it along to you :sunglasses:

1 Like

Okay, I fixed all migrated posts via the API using /posts/{num}/rebake. Oddly the rake posts:rebake command in the container didn’t work.

After automating the rebake API call, it turned out there’s about an 80% image upload failure rate. That’s pretty crazy.

4 Likes

In the end this turned out not to be reliable, it would work for a few posts but not for all. I’ll have to have another go at trying to upload the images again. I had issues with this before with requests just hanging. I’m not sure if I tried the skip_validations parameter on those requests though.

2 Likes

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

There are a couple of suggestions in this post that may be helpful for fixing broken images: Rebake with rails command or rake task doesn't work, but rebuilding HTML does. Why? - #12 by RGJ.

5 Likes