Rebaking posts fails when attachments aren't allowed anymore

I’m not sure if this can be called a bug, but it is an unexpected behavior:

Steps to reproduce:

  • Add a new file extension like tif to authorized_extensions
  • Attach a file with that extension to a post
  • Remove the file extension from authorized_extensions
  • Rebake all posts using rake posts:rebake

Expected behavior:
Rebaking of all posts should work, even though the previously attached file extension isn’t allowed anymore.

Actual behavior:
Rebaking of posts fails for all posts that have attachments which aren’t allowed anymore. They are stuck in the sidekiq retry queue. The error message is:

Job exception: Wrapped ActiveRecord::RecordInvalid: Validation failed: Original filename Sorry, the file you are trying to upload is not authorized (authorized extensions: jpg, jpeg, png, gif).

Additional information:
This error happens only with images. It doesn’t seem to happen with other file types.
Lowering max_image_size_kb also results in errors:

Job exception: Wrapped ActiveRecord::RecordInvalid: Validation failed: Filesize Sorry, the image you are trying to upload is too big (maximum size is 3072KB), please resize it and try again.

Hmm, you might need to re-enable that filetype before rebaking. I don’t know if I would classify this as a bug.

Mmm, I think that lowering the max image size should be a supported action.

1 Like

Re-enabling those file extensions is easier said then done.
Rebake doesn’t throw any error. So, this gets only noticed if you take a look at the Sidekiq queue and realize that there are way too many tasks in the retry queue.
And then you need to figure out which file extensions are missing. The error message doesn’t give a clue about the filename and extension. The same goes for the file size.

This might be an edge case (I noticed it after an import and rebake of all posts), but I think this should be handled somehow.

This is now fixed:
https://github.com/discourse/discourse/pull/3573

2 Likes

This topic was automatically closed after 3271 days. New replies are no longer allowed.