OCP\Files\NotFoundException on versions:expire

Hi all

After migration to AIO and some updates we see some of this errors in log:

OCP\Files\NotFoundException: /user/files/path/to/some/file.ext
/var/www/html/lib/private/Files/Node/Folder.php - line 138:
OC\Files\Node\Root->get("/user/fi...")
/var/www/html/apps/files_versions/lib/Storage.php - line 595:
OC\Files\Node\Folder->get("/path...")
<<closure>>
OCA\Files_Versions\Storage::OCA\Files_Versions\{closure}("*** sensiti ... *")
/var/www/html/apps/files_versions/lib/Storage.php - line 610:
array_filter([ "*** sensi ... "], [ "Closure"])
/var/www/html/apps/files_versions/lib/BackgroundJob/ExpireVersions.php - line 69:
OCA\Files_Versions\Storage::expireOlderThanMaxForUser("user")
/var/www/html/lib/private/User/Manager.php - line 639:
OCA\Files_Versions\BackgroundJob\ExpireVersions->OCA\Files_Versions\BackgroundJob\{closure}("*** sensiti ... *")
/var/www/html/apps/files_versions/lib/BackgroundJob/ExpireVersions.php - line 70:
OC\User\Manager->callForSeenUsers([ "Closure"])
/var/www/html/lib/public/BackgroundJob/Job.php - line 78:
OCA\Files_Versions\BackgroundJob\ExpireVersions->run(null)
/var/www/html/lib/public/BackgroundJob/TimedJob.php - line 103:
OCP\BackgroundJob\Job->start([ "OC\\BackgroundJob\\JobList"])
/var/www/html/lib/public/BackgroundJob/TimedJob.php - line 93:
OCP\BackgroundJob\TimedJob->start([ "OC\\BackgroundJob\\JobList"])
/var/www/html/cron.php - line 152:
OCP\BackgroundJob\TimedJob->execute([ "OC\\BackgroundJob\\JobList"], [ "OC\\Log"])

If we start the expire command manually, we get this error:

docker:/var/www/html$ php occ versions:expire
   25 [------->--------------------]
In Root.php line 209:                                                           
  /user/files/path/to/some/file.ext             
versions:expire [<user_id>...]

To fix this one error, we have to recreate the missing file:
touch /mnt/ncdata/user/files/path/to/some/file.ext

The next “occ versions:expire” will bring up the next file, until all errors are fixed.

Is there a way to do this automatically?

Nextcloud is running on Version 26.0.2.

Same for me. My solution for now is run php occ versions:cleanup but this command will delete all files versioning on all users and the error never came again until i remove the files from my external storage the error shows up again and again.

Same here (NC 27.0.2).

The reason seems to be files which got deleted but there are still old versions stored.

if the expire job sees a versioned file in data/<username>/files_versions it will try to find the original file in data/<username>/files and will fail when the file does not exist any longer.

I am not sure when exactly this bug was introduced, but I know in older Nextcloud versions it worked.

I also posted an issue at Github about this: