Open lars-sh opened 3 years ago
Thanks for your report :+1:
I'm not sure how to reproduce this error but $path (that's the 3rd argument for setObject) can be null. Can you apply the patch below. It should fix the actual error and log the path that resolves to null. Please make sure to set the loglevel to 1 to log the message.
Index: lib/Item.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/Item.php b/lib/Item.php
--- a/lib/Item.php (revision 86a47e75938470922c130098971efc2fdb11b46b)
+++ b/lib/Item.php (date 1632772059571)
@@ -104,11 +104,15 @@
$userFolder = $this->rootFolder->getUserFolder($this->file->getOwner()->getUID());
$path = $userFolder->getRelativePath($this->file->getPath());
+ if ($path === null) {
+ $this->logger->notice('getRelativePath is null for "' . $this->file->getPath() . '"', ['app' => 'files_antivirus_199']);
+ }
+
$activity = $this->activityManager->generateEvent();
$activity->setApp(Application::APP_NAME)
->setSubject(Provider::SUBJECT_VIRUS_DETECTED_SCAN, [$status->getDetails()])
->setMessage($message)
- ->setObject('file', $this->file->getId(), $path)
+ ->setObject('file', $this->file->getId(), $path ?? '')
->setAffectedUser($this->file->getOwner()->getUID())
->setType(Provider::TYPE_VIRUS_DETECTED);
$this->activityManager->publish($activity);
Thanks @kesselb, I should have been able to get closer to the problem itself on my own :man_facepalming: I'll head back once I have more information.
OK, here we go.
The log output is as follows. I just remove a specific internal portion to avoid it to be public.
getRelativePath is null for "/avagt/files/KG-Oldesloe/[...]/Trash" File: 489783 Account: admin Path: /avagt/files/KG-Oldesloe/[...]/Trash
And this is where that file should be found in the file system, including the ls
output for additional information:
ls -al "/mnt/data/data/admin/files/KG Oldesloe/[...]/Trash"
-rw-r--r-- 1 www-data www-data 16521517 May 6 2018 '/mnt/data/data/admin/files/KG Oldesloe/[...]/Trash'
That does not seem to be wrong to me. And just to make it clear: There are other files with similar permissions in the same folder, that do not seem to raise that error.
I just had a look at the method getRelativePath
and to me it seems, it fails at https://github.com/nextcloud/server/blob/67e6468b9e5a6fb30638158c7bd558307d5ff747/lib/private/Files/Node/Folder.php#L85 , right?
Steps to reproduce
Since some time now the antivirus app writes about 50 errors a day to our server logs. We don't know, what might cause that type error, therefore there are no known steps to reproduce this problem for now.
Expected behaviour
No unexpected errors in the logs.
Actual behaviour
Unexpected error (see below log entry) in the logs.
Server configuration
Operating system: Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)
Web server: Apache 2.4.41
Database: MariaDB 10.3.29
PHP version: 7.4.3
Nextcloud version: 21.0.3.1
Logs
Nextcloud log