There may have some gallery that don’t have files property attached. Try running in your database…
SELECT sg.galley_id, sg.file_id FROM publication_galleys sg LEFT JOIN submission_files sf ON (sf.file_id = sg.file_id) WHERE sf.file_id IS NULL;
You have to review the return values. There may be incorrect file ID.