diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index 735d8900c8d9d..a3830afa089e0 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -35,7 +35,6 @@ Turning the feature off removes shared files and folders on the server for all s
OCA\Files_Sharing\ExpireSharesJob
OCA\Files_Sharing\SharesReminderJob
OCA\Files_Sharing\BackgroundJob\FederatedSharesDiscoverJob
- OCA\Files_Sharing\BackgroundJob\ExternalShareScanJob
diff --git a/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php b/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php
index 597e19bbcebe1..71379c8b11f11 100644
--- a/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php
+++ b/apps/files_sharing/lib/BackgroundJob/ExternalShareScanJob.php
@@ -35,6 +35,10 @@ protected function run($argument): void {
}
[$userId, $path] = $argument;
+ if ($userId === null || $userId === '') {
+ return;
+ }
+
try {
$this->rootFolder
->getUserFolder($userId)