Broken images and attachments on old issues

Images and other issue attachments are returning a 404, and inline images are not displaying. Clicking on the broken inline image yields a 404 page. This only affects uploads made prior to early 2018, which don’t have a ‘secret’ field value in the uploads database. Here is an example:

For newer uploads, the image displays inline, and clicking the link yields the image as expected.

The files and permissions look fine on the filesystem.

The working images have a ‘secret’ field in the uploads database table. The broken images are missing the ‘secret’ field.

We have two self-managed GitLab-CE 12.10.2 instances affected by this problem. We update regularly, and uploads have a secret starting around 2018-03-11.

Is this a bug that can be fixed in gitlab? Or is there a process we need to apply to generate secrets on old images? Should I submit this as a bug report in the issue tracker?

I ended up fixing it on our site with the following SQL commands, I can’t promise this will work perfectly in all cases:

CREATE TABLE uploads_backup AS TABLE uploads;

update uploads SET secret = SUBSTRING(path, 0, 33) where secret IS NULL AND (uploader = ‘FileUploader’ OR uploader = ‘PersonalFileUploader’);