Closed simonspa closed 2 months ago
@simonspa Do you also expierence the issue that COOL is unable to save the document then? In our case a user creates a file in COOL, but when he want's to save it, the issue appears.
That's a good question @bjo81 that I unfortunately cannot really answer. This only happened in other user sessions so far and I have only observed the above message in the log. I don't know how the UX is in that moment. I will try to inquire with them but since it's been a few days they might not remember.
I've seen this as well and thought it was an issue in the richdocuments app at first (see https://github.com/nextcloud/richdocuments/issues/3169), but it looks like it's something with the files_version
app.
In my case the file in question was shared from a groupfolder, but looking at the enabled apps above, groupfolders are not enabled on your installation, is that correct? So in that case, I can remove groupfolders as the responsible app in my thinking.
The error does appear when the user tries to save a (shared with him) document. Sometimes a message pops up saying something about missing permissions and unable to save. The changes are then lost.
I've seen this on 27.0.2 and also on 27.1 RC2.
Also CC @artonge
I can definitely confirm that I do not have the group folders app enabled.
I am wondering if the try-catch is enough here:
if I understand correctly, this calls getRelativePath
from OC\Files\Utils\PathHelper
(?) but this can return null
instead of throwing an exception?
But that's just blind guessing on my end since I am not familiar with the code. On my testinstance I have disabled files_versions
app for now and it seems to work fine now... Let's see.
@artonge Hi. Can you please take a look?
There is a method OCA\Files_Versions\Listener\FileEventsListener::getPathForNode, and it appears that you have created it (commit: https://github.com/nextcloud/server/commit/3da63f4148898ec4bc9544a4a9ef07bac3e07669).
I have studied the operation of this method, and I believe it would make sense to remove the exception handling from it.
Why?
Example 1
Alice has the file Alice\files\study\homework.odt (file in folder). She shared this file with Bob. Bob is editing this file. When saved, $node->getPath() in the getPathForNode method will have the value "Bob\files\homework.odt". If it was not possible to connect to the Bob folder. Will try to get RelativePath from Bob\files\homework.odt relative to Alice\files and it will return null As a result, we will get the error that the author of this issue complains about.
Example 2
I thought it would make sense to rewrite the exception handling:
$ownerFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUid());
$ownerNode = $ownerFolder->getById($node->getId());
return $ownerFolder->getRelativePath($ownerNode ->getPath());
\study\homework.odt will then be returned
And then in the OCA\Files_Versions\Store::store method there is a Filesystem::file_exists($filename) check against Bob (he has \homework.odt, not \study\homework.odt). As a result, Store::store will not work correctly.
Based on these two cases, I have the impression that the system will work more smoothly without handling this exception.
} catch (\Throwable $ex) {
return $this->rootFolder
->getUserFolder($node->getOwner()->getUid())
->getRelativePath($node->getPath());
}
But I have relatively recently started studying Nextcloud, so I would be very grateful if you could evaluate the correctness of these conclusions.
Hi @AIlkiv I do barely understand, what you are doing. But I was desperately in need of a solution and used your rewrite: it works for me (!). You don't need the second line, though? $ownerNode will not be used in the following lines. Cheers, Tobias
I've seen this on 27.0.2 and also on 27.1 RC2.
Also CC @artonge
Beside myself having the problem: see here I found another user from long time/version ago: https://help.nextcloud.com/t/collabora-on-mobile-cant-save-edited-documents-in-shared-folders/69272/2 Even if the bug is not that old, is there a chance to get this fixed without having to disable files_versions ?
I do barely understand, what you are doing. But I was desperately in need of a solution and used your rewrite: it works for me (!). You don't need the second line, though? $ownerNode will not be used in the following lines.
This is not a solution. It should not be used.
There was a mistake, I corrected the comment return $ownerFolder->getRelativePath($ownerNode->getPath());
.
Hi @AIlkiv , thanks for the correction. However, I tried a couple of things and the main problem is indeed that getRelativePath() is empty - iff the path of the node does not fit to the current user.
So, from where my problem comes: $node->getPath() is already Alice\files\study\homework.odt
. This seems to be a problem steming from the richdocuments-App.... the same thing in the browser, and $node->getPath() is Bob\...
And one more thing: your proposal does not work, since $ownerFolder->getById($node->getId())
returns an array of possible Nodes/Folders. One would have to adjust this atleast.
I have used this workaround now:
private function getPathForNode(Node $node): ?string {
$ownerFolder = $this->rootFolder->getUserFolder($node->getOwner()->getUid());
try {
$relativepath = $this->rootFolder
->getUserFolder(\OC_User::getUser())
->getRelativePath($node->getPath());
if ($relativepath === null) {
$this->logger->error('Relative Path null of Node Path: ' . $node->getPath() . '; User: ' . \OC_User::getUser());
$relativepath = $ownerFolder->getRelativePath($node->getPath());
}
} catch (\Throwable $ex) {
$relativepath = $ownerFolder->getRelativePath($node->getPath());
}
return $relativepath;
}
@jolly-jump In which case path may not be from the current user?
I checked the following situations:
In both cases, I had the correct path.
@AIlkiv
I am talking about the situation, where bob edits a file shared from alice.
When bob uses the Nextcloud-App to open a document with collabora and saves it (or closes it).
Then: the \OC_User::getUser() = "bob"
and the $node->getPath() = /alice/files/study/homework.odt
(the $ownerNode->getPath()
is obviously the same
When opening the same file in the browser by bob:
Then: the \OC_User::getUser() = bob
and the $node->getPath() = /bob/files/homework.odt
, the $ownerNode
returns the path in Alices acount.
I admit, I haven't tested a subdirectory like "study" in the account of Alice.
Thus: for the webediting everything works already out of the box (the try-part of the exception handling works). For the mobile editing part, the try-part works as well and does not throw an exception, but the relativePath-string is "null", since $node is already the "$ownerNode".
Thus the "catch"-part is never reached (in these two situations).
I get this error trying to run encryption:encrypt-all
:
$ php occ encryption:encrypt-all"
You are about to encrypt all files stored in your Nextcloud installation.
Depending on the number of available files, and their size, this may take quite some time.
Please ensure that no user accesses their files during this time!
Note: The encryption module you use determines which files get encrypted.
Do you really want to continue? (y/n) y
Encrypt all files with the Default encryption module
====================================================
Create key-pair for every user
------------------------------
This module will encrypt all files in the users files folder initially.
Already existing versions and files in the trash bin will not be encrypted.
Key-pair created for all users
[->--------------------------]
Generated encryption key passwords
----------------------------------
All users already had a key-pair, no further action needed.
Start to encrypt users files
----------------------------
%message%
[>---------------------------]An unhandled exception has been thrown:
TypeError: OC\Files\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/html/lib/private/Files/View.php on line 528 and defined in /var/www/html/lib/private/Files/View.php:1128
Stack trace:
#0 /var/www/html/lib/private/Files/View.php(528): OC\Files\View->basicOperation('file_exists', NULL)
#1 /var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php(345): OC\Files\View->file_exists(NULL)
#2 /var/www/html/apps/files_versions/lib/Listener/FileEventsListener.php(132): OCA\Files_Versions\Listener\FileEventsListener->pre_renameOrCopy_hook(Object(OC\Files\Node\File), Object(OC\Files\Node\File))
#3 /var/www/html/lib/private/EventDispatcher/ServiceEventListener.php(86): OCA\Files_Versions\Listener\FileEventsListener->handle(Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent))
#4 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(251): OC\EventDispatcher\ServiceEventListener->__invoke(Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent), 'OCP\\Files\\Event...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#5 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'OCP\\Files\\Event...', Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent))
#6 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(94): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent), 'OCP\\Files\\Event...')
#7 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(106): OC\EventDispatcher\EventDispatcher->dispatch('OCP\\Files\\Event...', Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent))
#8 /var/www/html/lib/private/Files/Node/HookConnector.php(187): OC\EventDispatcher\EventDispatcher->dispatchTyped(Object(OCP\Files\Events\Node\BeforeNodeRenamedEvent))
#9 /var/www/html/lib/private/legacy/OC_Hook.php(105): OC\Files\Node\HookConnector->rename(Array)
#10 /var/www/html/lib/private/Files/View.php(760): OC_Hook::emit('OC_Filesystem', 'rename', Array)
#11 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(302): OC\Files\View->rename('/christopher@mi...', '/christopher@mi...')
#12 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(274): OCA\Encryption\Crypto\EncryptAll->encryptFile('/christopher@mi...')
#13 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(222): OCA\Encryption\Crypto\EncryptAll->encryptUsersFiles('christopher@mir...', Object(Symfony\Component\Console\Helper\ProgressBar), 'christopher@mir...')
#14 /var/www/html/apps/encryption/lib/Crypto/EncryptAll.php(168): OCA\Encryption\Crypto\EncryptAll->encryptAllUsersFiles()
#15 /var/www/html/apps/encryption/lib/Crypto/Encryption.php(551): OCA\Encryption\Crypto\EncryptAll->encryptAll(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/core/Command/Encryption/EncryptAll.php(116): OCA\Encryption\Crypto\Encryption->encryptAll(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OC\Core\Command\Encryption\EncryptAll->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/3rdparty/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OC\Core\Command\Encryption\EncryptAll), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/console.php(100): OC\Console\Application->run()
#23 /var/www/html/occ(11): require_once('/var/www/html/c...')
#24 {main}command terminated with exit code 1
Any idea what's happening, here?
When I disable the version app, the problem is solved. The version of the version app is 1.20.0 Is this solved in a newer version?
Could one of you, that experience the issue, apply the following patch and check what kind of file causes the issue for them?
This will create a log when getPathForNode
return a null value.
Applied the patch and re-enabled files_versions. Lets see. I was unable to reproduce it on purpose, only when someone complained that the data they entered in Nextcloud Office was lost.
@jakobroehrl Is it reproducable for you each time?
That was fast, logged the error below. Just to mention it, this happens for me when trying to edit a shared document from the iOS Files app. And I see that @jakobroehrl linked to the Android app. Maybe there's something different when opening richdocuments in a webview in contrast to accessing it through the nextcloud UI?
{
"reqId": "OBWbUL7unF4Oo5oYPnws",
"level": 3,
"time": "2023-12-14T17:50:50+01:00",
"remoteAddr": "172.30.150.2",
"user": "test",
"app": "richdocuments",
"method": "POST",
"url": "//index.php/apps/richdocuments/wopi/files/866619_oc4r8rpp6vq8/contents?access_token=....&access_token_ttl=1702608560000",
"message": see below
"userAgent": "COOLWSD HTTP Agent 23.05.5.4",
"version": "28.0.0.11"
}
Exception:
{
"Exception": "Exception",
"Message": "Object of class OC\\User\\LazyUser could not be converted to string in file '/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php' line 197",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 184,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 315,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1069,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
},
{
"file": "/var/www/nextcloud/index.php",
"line": 39,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"Line": 169,
"Previous": {
"Exception": "Error",
"Message": "Object of class OC\\User\\LazyUser could not be converted to string",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
"line": 102,
"function": "write_hook",
"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php",
"line": 86,
"function": "handle",
"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 230,
"function": "__invoke",
"class": "OC\\EventDispatcher\\ServiceEventListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 59,
"function": "callListeners",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 94,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 106,
"function": "dispatch",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Node/HookConnector.php",
"line": 100,
"function": "dispatchTyped",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
"line": 105,
"function": "write",
"class": "OC\\Files\\Node\\HookConnector",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/View.php",
"line": 596,
"function": "emit",
"class": "OC_Hook",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/private/Files/View.php",
"line": 639,
"function": "emit_file_hooks_pre",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Node/File.php",
"line": 73,
"function": "file_put_contents",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 512,
"function": "putContent",
"class": "OC\\Files\\Node\\File",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 804,
"function": "OCA\\Richdocuments\\Controller\\{closure}",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 781,
"function": "retryOperation",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Lock/LockManager.php",
"line": 39,
"function": "OCA\\Richdocuments\\Controller\\{closure}",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 784,
"function": "runInScope",
"class": "OC\\Files\\Lock\\LockManager",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 511,
"function": "wrappedFilesystemOperation",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 230,
"function": "putFile",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 137,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 184,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 315,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1069,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
},
{
"file": "/var/www/nextcloud/index.php",
"line": 39,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
"Line": 197
},
"message": "Uncaught error: Object of class OC\\User\\LazyUser could not be converted to string in file '/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php' line 197",
"exception": {},
"CustomMessage": "Uncaught error: Object of class OC\\User\\LazyUser could not be converted to string in file '/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php' line 197"
}
Ah, forgot to add ->getUID()
at the end :see_no_evil:. Sorry, can you try again with this patch?
When I disable the version app, the problem is solved.
Thank you for this @jakobroehrl, that's allowing me to actually encrypt files.
Sorry, can you try again with this patch?
Sure 👍
Here you go:
With "marcel.mueller" being the user who shared the file and "test" the user who tried to edit on an iPhone.
{
"reqId": "mhRiDveSa3WjEDte4j6D",
"level": 3,
"time": "2023-12-14T18:08:41+01:00",
"remoteAddr": "172.30.150.2",
"user": "test",
"app": "files_versions",
"method": "POST",
"url": "//index.php/apps/richdocuments/wopi/files/866619_oc4r8rpp6vq8/contents?access_token=...&access_token_ttl=1702609577000",
"message": "Failed to find relative path for file for /marcel.mueller/files/Gesch\u00e4ftsleitung/SubFolder/File.xlsx and owner test",
"userAgent": "COOLWSD HTTP Agent 23.05.5.4",
"version": "28.0.0.11",
"data": {
"app": "files_versions"
}
}
For testing I moved the logging part to the outside of the if, so it's logged in all cases.
When I log in as user "test" and edit the file in Web, this happens:
{
"reqId": "lB7HzB0OuD1lzetbfqqW",
"level": 3,
"time": "2023-12-14T20:28:36+01:00",
"remoteAddr": "172.30.150.2",
"user": "test",
"app": "files_versions",
"method": "POST",
"url": "//index.php/apps/richdocuments/wopi/files/866619_oc4r8rpp6vq8/contents?access_token=....&access_token_ttl=0",
"message": "Found relative path for file for /test/files/SharedFolder/File.xlsx and owner marcel.mueller",
"userAgent": "COOLWSD HTTP Agent 23.05.5.4",
"version": "28.0.0.11",
"data": {
"app": "files_versions"
}
}
When I edit the same file on iOS this happens (still user "test"):
{
"reqId": "BweWs7paOuwiU9WQRbL2",
"level": 3,
"time": "2023-12-14T20:29:11+01:00",
"remoteAddr": "172.30.150.2",
"user": "test",
"app": "files_versions",
"method": "POST",
"url": "//index.php/apps/richdocuments/wopi/files/866619_oc4r8rpp6vq8/contents?access_token=....&access_token_ttl=1702618112000&permission=edit",
"message": "Failed to find relative path for file for /marcel.mueller/files/Gesch\u00e4ftsleitung/SharedFolder/File.xlsx and owner test",
"userAgent": "COOLWSD HTTP Agent 23.05.5.4",
"version": "28.0.0.11",
"data": {
"app": "files_versions"
}
}
Edit web:
Edit iOS:
I experience this every time a office doc was edited by a mobile app. The mobile call is different to the browser call: https://github.com/nextcloud/server/issues/40090#issuecomment-1750762886 But I do not understand why it does not occur on my AIO installation. Same nc version, same versions app version (version app is enabled)
Ah, forgot to add
->getUID()
at the end 🙈. Sorry, can you try again with this patch?
How can I apply this patch?
Could https://github.com/nextcloud/server/pull/42075 and https://github.com/nextcloud/richdocuments/pull/3340 fix the issue? For 27, the richdocuments part is not yet released, but if one of you updated to 28, the PRs should be included.
but if one of you updated to 28, the PRs should be included.
My tests above were all made with 28. so I guess this does not fix it ?
My tests above were all made with 28. so I guess this does not fix it ?
Can you check the version of richdocuments?
Which richdocuments release contains the fix? 8.3.0? https://github.com/nextcloud/richdocuments/releases
https://github.com/nextcloud/richdocuments/pull/3340 is a backport of https://github.com/nextcloud/richdocuments/pull/3330 Is it right, that this requires NC29? https://github.com/nextcloud/server/pull/41944
Yes, 8.3.0 contains the fix. 28 is enough
Retested on 28.0.1.0 with richdocuments 8.3.0, same error
I tried to take a look if the problem comes from richdocuments and checked this code part:
As you can see on the left side, the path is already different in the richdocuments app.
$wopi->getUserForFileAccess()
returns bob
in the working case, and admin
in the not working one.
returns true
in the iOS case which returns the ownerUid at https://github.com/nextcloud/richdocuments/blob/4ac2f9379937dd3148b39d8cd3a0726856bf8c46/lib/Db/Wopi.php#L175
iOS has a wopi tokenType of 1, while a browser has a tokenType of 0.
I tried to take a look if the problem comes from richdocuments
FYI, I have this issue, and don't have richdocuments.
Retested on 28.0.1.0 with richdocuments 8.3.0, same error
same on my site
Ah, forgot to add
->getUID()
at the end 🙈. Sorry, can you try again with this patch?
applying this patch while debugging this error also happening within multiboards app the following log comes up:
{"reqId":"aF19X6Z9SeoNw7KRMfLe","level":3,"time":"2024-01-14T14:03:24+00:00","remoteAddr":"127.0.0.1","user":"user2","app":"files_versions","method":"PUT","url":"/index.php/apps/multiboards/file/save?fileId=null&shareToken=tN9LqDcZ5qcYScD","message":"Failed to find relative path for file for /admin/files/MultiBoard 14 Jan 2024 101608 GMT.mboard and owner admin","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0","version":"28.0.1.1","data":{"app":"files_versions"}}
thing is it does not happen if the logged in user is the same user who created and shared the file of relevance, it only happens if another NC user is logged in, tries to access the file via sharetoken, and then this error throws..
I tried to take a look if the problem comes from richdocuments
FYI, I have this issue, and don't have richdocuments.
@kyrofa Would you mind sharing your stack trace, too?
Hey, could one of you test the following PR: https://github.com/nextcloud/server/pull/42891 ?
Hey, could one of you test the following PR: #42891 ?
Hey, couldn't test it too much, but a quick test showed no exception and a version being created! Thanks!
Hey, could one of you test the following PR: #42891 ?
for me and a quick test it looks like this:
[x]
fixes the issue[dont know]
side effectsFixed for me with the latest NC version, I actived the version App again.
Hey, just want to tell you that I'm having the same Problem, disabling Versions solves the Problem it seems.
I'm on: Versions 1.21.0 NextCloudPi 28.0.3 Backup 1.4.0
No Richdocuments or Office installed.
Please tell me if I can do anything to help you figuring this out.
Please tell me if I can do anything to help you figuring this out.
What could help would be to add the following lines in apps/files_versions/lib/Listener/FileEventsListener.php
, right before the last return null;
.
$this->logger->error('Failed to find relative path for file for ' . $node->getPath() . ' and owner ' . $node->getOwner()->getUID());
And then to trigger the error again, and to post the generated logs here.
Please tell me if I can do anything to help you figuring this out.
What could help would be to add the following lines in
apps/files_versions/lib/Listener/FileEventsListener.php
, right before the lastreturn null;
.$this->logger->error('Failed to find relative path for file for ' . $node->getPath() . ' and owner ' . $node->getOwner()->getUID());
And then to trigger the error again, and to post the generated logs here.
I'm sorry, I gave up on the backup app. I was trying for 2 days and I'm tired of this app. Using Borg now, works like a charm.
And then to trigger the error again, and to post the generated logs here.
We have the same issue, latest version of Collabora (coolwsd 24.04.1.4) and Nextcloud v28.0.5:
Failed to find relative path for file for /<user name 1>/files/<group folder>/<file path inside group folder>.docx and owner <user name 2>
user name 1: the user who I presume created the document user name 2: myself when I try to edit the file
I am also seeing the exception again. Here is the log as requested:
{
"reqId": "dzYhDuN388vLllOuTTuc",
"level": 3,
"time": "2024-05-05T15:19:33+02:00",
"remoteAddr": "172.30.150.2",
"user": "test",
"app": "files_versions",
"method": "POST",
"url": "/index.php/apps/richdocuments/wopi/files/..../contents?access_token=....&access_token_ttl=0",
"message": "Failed to find relative path for file for /marcel.mueller/files/<Folder>/<Subfolder>/2024.xlsx and owner test",
"userAgent": "COOLWSD HTTP Agent 24.04.1.4",
"version": "29.0.0.19",
"data": {
"app": "files_versions"
}
}
Notes:
<Folder>
is a groupfoldermarcel.mueller
shared the folder <Subfolder>
with user test
test
tries to edit the file via the iOS files appWhen I add an additional log to the beginning of the getPathForNode
function and try the same via the Web (so not iOS), like this:
$this->logger->error('Trying to find relative path for file for ' . $node->getPath() . ' and owner ' . $node->getOwner()->getUID());
I get:
Trying to find relative path for file for /test/files/<Subfolder>/2024.xlsx and owner marcel.mueller
and a version is created (so user and owner are swapped).
What works for me is to still try to get the owner based on the path:
diff --git a/apps/files_versions/lib/Listener/FileEventsListener.php b/apps/files_versions/lib/Listener/FileEventsListener.php
index 3273f1f9c40..b3254b0e424 100644
--- a/apps/files_versions/lib/Listener/FileEventsListener.php
+++ b/apps/files_versions/lib/Listener/FileEventsListener.php
@@ -403,6 +403,22 @@ class FileEventsListener implements IEventListener {
}
}
+ // Try to get the owner of the file based on the path as a fallback
+ $parts = explode('/', $node->getPath(), 4);
+ if (count($parts) === 4) {
+ $owner = $parts[1];
+
+ $path = $this->rootFolder
+ ->getUserFolder($owner)
+ ->getRelativePath($node->getPath());
+
+ if ($path !== null) {
+ return $path;
+ }
+ }
+
What I still don't get, why is the user/owner swapped when editing the file on the iOS app in the first place?
What I still don't get, why is the user/owner swapped when editing the file on the iOS app in the first place?
Judging from https://github.com/nextcloud/server/pull/44294#issuecomment-2042599497 that seems expected.
Also https://github.com/nextcloud/richdocuments/pull/3558 recently changed the user when editing, which could also make a difference here I guess.
@juliushaertl Maybe there’s a better way to get the path in this scenario with Collabora ?
I worked on a better approach for storages that do not have a dedicated owner with https://github.com/nextcloud/server/pull/44294 https://github.com/nextcloud/groupfolders/pull/2872 That way we would no longer need to get the path but could just use the storage provided user id
@juliushaertl I upgraded to 30 RC, both PRs are included, still I am unable to edit shared richdocuments files. The only way to make it work is to apply the patch I posted at https://github.com/nextcloud/server/issues/40090#issuecomment-2094819016.
Is there still something missing or should it work?
Here's the log:
{
"Exception": "Exception",
"Message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/View.php on line 492 in file '/var/www/nextcloud/lib/private/Files/View.php' line 1103",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 996,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
},
{
"file": "/var/www/nextcloud/index.php",
"line": 24,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"Line": 146,
"Previous": {
"Exception": "TypeError",
"Message": "OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/View.php on line 492",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/Files/View.php",
"line": 492,
"function": "basicOperation",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
"line": 516,
"function": "file_exists",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/files_versions/lib/Storage.php",
"line": 158,
"function": "file_exists",
"class": "OC\\Files\\Filesystem",
"type": "::"
},
{
"file": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
"line": 174,
"function": "store",
"class": "OCA\\Files_Versions\\Storage",
"type": "::"
},
{
"file": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
"line": 80,
"function": "write_hook",
"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php",
"line": 68,
"function": "handle",
"class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 230,
"function": "__invoke",
"class": "OC\\EventDispatcher\\ServiceEventListener",
"type": "->"
},
{
"file": "/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
"line": 59,
"function": "callListeners",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 67,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
"line": 79,
"function": "dispatch",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Node/HookConnector.php",
"line": 74,
"function": "dispatchTyped",
"class": "OC\\EventDispatcher\\EventDispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/legacy/OC_Hook.php",
"line": 82,
"function": "write",
"class": "OC\\Files\\Node\\HookConnector",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/View.php",
"line": 560,
"function": "emit",
"class": "OC_Hook",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/private/Files/View.php",
"line": 603,
"function": "emit_file_hooks_pre",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Node/File.php",
"line": 52,
"function": "file_put_contents",
"class": "OC\\Files\\View",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 467,
"function": "putContent",
"class": "OC\\Files\\Node\\File",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 756,
"function": "OCA\\Richdocuments\\Controller\\{closure}",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 733,
"function": "retryOperation",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Files/Lock/LockManager.php",
"line": 68,
"function": "OCA\\Richdocuments\\Controller\\{closure}",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->",
"args": [
"*** sensitive parameters replaced ***"
]
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 736,
"function": "runInScope",
"class": "OC\\Files\\Lock\\LockManager",
"type": "->"
},
{
"file": "/var/www/nextcloud/apps/richdocuments/lib/Controller/WopiController.php",
"line": 466,
"function": "wrappedFilesystemOperation",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "putFile",
"class": "OCA\\Richdocuments\\Controller\\WopiController",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::"
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 996,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->"
},
{
"file": "/var/www/nextcloud/index.php",
"line": 24,
"function": "handleRequest",
"class": "OC",
"type": "::"
}
],
"File": "/var/www/nextcloud/lib/private/Files/View.php",
"Line": 1103
},
"message": "Uncaught error: OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/View.php on line 492 in file '/var/www/nextcloud/lib/private/Files/View.php' line 1103",
"exception": {},
"CustomMessage": "Uncaught error: OC\\Files\\View::basicOperation(): Argument #2 ($path) must be of type string, null given, called in /var/www/nextcloud/lib/private/Files/View.php on line 492 in file '/var/www/nextcloud/lib/private/Files/View.php' line 1103"
}
Indeed, i could reproduce that, could you check the patch in https://github.com/nextcloud/richdocuments/pull/3948 and see if that does the trick for you?
⚠️ This issue respects the following points: ⚠️
Bug description
Yesterday, the below stack trace appeared several hundred times in my Nextcloud 27.0.2 log. From the trace I infer that user BBBB shared an ODS file with user AAAA and the latter is trying to open it (or save it? The user agent is "COOLWSD".)
Whatever is happening, in the end a method requests a string but obtains
null
.Steps to reproduce
(log entries)
Expected behavior
The requested operation succeeds.
Installation method
Community Manual installation with Archive
Nextcloud Server version
27
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Nginx
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 22 to 23)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response