Error upgrading from 2.4.8 to 3.1.1: "Invalid file!"

It looks like you have already seen the thread here:

Pointing to pkp/pkp#3783 consider supp files without file id in the migration by bozana · Pull Request #2009 · pkp/ojs · GitHub

I also found this error to arise when a supplementary file entry exists in OJS but there is no corresponding submission file. Specifically:

SELECT a.context_id, sf.* FROM article_supplementary_files sf, submissions a WHERE a.submission_id = sf.article_id AND sf.file_id <> 0 AND sf.show_reviewers = 1 AND sf.remote_url IS NULL and sf.file_id not in (select f.file_id from submission_files f);

This presents in the user interface as a supplementary file with no file information:

I’m testing a patch adding the and sf.file_id in (select f.file_id from submission_files f) to: