nextcloud / nextcloud/context_chat
Embedding files can fail, when storage has multiple shared mounts
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 29
- Forks
- 12
- Avg merge
- 4d 4h
- Merged PRs (30d)
- 5
Description
Which version of Nextcloud are you using?
v34.0.1
Which version of PHP context_chat are you using?
5.4.0
Which version of backend context_chat are you using?
5.4.0
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
Firefox 152.0.3
Nextcloud deployment method?
AIO
Describe the Bug
After installing context_chat and context_chat_backend, I had the issue that only 1.7k of 10k eligible files were written to the vector database.
When trying to debug the issue, I found a lot of File not found or not a file errors triggered by the /ocs/v2.php/apps/context_chat/queues/documents?n=32&format=json endpoint. This happened even though I ran a full file scan before installing Context Chat.
I think root cause is $userId = $mounts[0]->getUser()->getUID() in OCA\ContextChat\Controller\QueueController::getFileSource().
It chooses a user by taking the first mount returned from IUserMountCache::getMountsForStorageId($storageId).
On a storage with many shared mounts, the first result is not always the owner / it can belong to a user that cannot access the queued file ID.
In this case getFirstNodeById($fileId) returns null and QueueController logs File not found or not a file.
To Reproduce
- Install a clean Nextcloud
32.0.0instance. - Create three users:
owner,aaa, andbbb. - As
owner, create an eligible test file:/owner/files/Test-Text.md - As
owner, create another folder on the same home storage:/owner/files/other/ - Share
Test-Text.mdwithaaa. - Share
other/withbbb. - Login as
aaaand openTest-Text.md - Login as
bbband openother/ - The returned mount order when calling
getMountsForStorageId()should be:owner /owner/ aaa /aaa/files/Test-Text.md/ bbb /bbb/files/other/ - Logout all users
- Upgrade the instance to Nextcloud
33, then to Nextcloud34.- This triggers
$this->connection->truncateTable('mounts', false);in https://github.com/nextcloud/server/blob/stable34/core/Migrations/Version33000Date20251209123503.php#L28 - Important: Do not trigger
files:scan --allor similar, this will affect the next step.
- This triggers
- After the upgrade, access the users in the following order via WebDAV (this fills
oc_mountsagain, but in a different order):curl -u bbb:<password> http://<nextcloud>/remote.php/dav/files/bbb/ curl -u aaa:<password> http://<nextcloud>/remote.php/dav/files/aaa/ curl -u owner:<password> http://<nextcloud>/remote.php/dav/files/owner/ - Call
getMountsForStorageId()again, the returned mount order should have changed:bbb /bbb/files/Other/ aaa /aaa/files/Test-Text.md/ owner /owner/ - Install and enable
context_chat5.4.0andcontext_chat_backend. - Trigger the initial indexing.
- You should see
File not found or not a filein the logs, because$userId = $mounts[0]->getUser()->getUID();returns a user who doesn't have access toTest-Text.mdnow.
I'm happy to provide a vServer with an affected Nextcloud instance if needed. Just let me know.
PHP logs (Warning these might contain sensitive information)
No response
Ex-App logs (Warning these might contain sensitive information)
No response
Server logs (if applicable)
{
"reqId": "XJEkVDoB8Qajy8bOA0WC",
"level": 2,
"time": "2026-07-01T16:57:02+00:00",
"remoteAddr": "XXX.XXX.XXX.XXX",
"user": "--",
"app": "context_chat",
"method": "GET",
"url": "/ocs/v2.php/apps/context_chat/queues/documents?n=32&format=json",
"scriptName": "/ocs/v2.php",
"message": "File not found or not a file",
"userAgent": "ExApp/context_chat_backend/5.4.0 (niquests/3.19.1)",
"version": "34.0.1.2",
"exception": {
"Exception": "Exception",
"Message": "File not found or not a file",
"Code": 0,
"Trace": [
{
"file": "/var/www/html/custom_apps/context_chat/lib/Controller/QueueController.php",
"line": 125,
"function": "getFileSource",
"class": "OCA\\ContextChat\\Controller\\QueueController",
"type": "->",
"args": [
{ "__class__": "OCA\\ContextChat\\Db\\QueueFile", "id": 24118 },
{ "__class__": "OC\\Files\\Node\\LazyRoot" },
{ "__class__": "OCA\\ContextChat\\Service\\StorageService" },
{ "__class__": "OC\\Files\\Config\\UserMountCache" }
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 165,
"function": "getDocumentsQueueItems",
"class": "OCA\\ContextChat\\Controller\\QueueController",
"type": "->",
"args": [
{ "__class__": "OCA\\ContextChat\\Service\\StorageService" },
{ "__class__": "OC\\Files\\Node\\LazyRoot" },
{ "__class__": "OCA\\ContextChat\\Db\\QueueMapper" },
{ "__class__": "OCA\\ContextChat\\Db\\QueueContentItemMapper" },
{ "__class__": "OC\\Files\\Config\\UserMountCache" },
32
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 78,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [ { "__class__": "OCA\\ContextChat\\Controller\\QueueController" }, "getDocumentsQueueItems" ]
},
{
"file": "/var/www/html/lib/private/AppFramework/App.php",
"line": 137,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [ { "__class__": "OCA\\ContextChat\\Controller\\QueueController" }, "getDocumentsQueueItems" ]
},
{
"file": "/var/www/html/lib/private/Route/Router.php",
"line": 324,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\ContextChat\\Controller\\QueueController",
"getDocumentsQueueItems",
{ "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer" },
{ "_route": "ocs.context_chat.queue.getdocumentsqueueitems" }
]
},
{ "file": "/var/www/html/ocs/v1.php", "line": 63, "function": "match", "class": "OC\\Route\\Router", "type": "->", "args": [ "/ocsapp/apps/context_chat/queues/documents" ] },
{ "file": "/var/www/html/ocs/v2.php", "line": 10, "args": [ "/var/www/html/ocs/v1.php" ], "function": "require_once" }
],
"File": "/var/www/html/custom_apps/context_chat/lib/Controller/QueueController.php",
"Line": 301,
"message": "File not found or not a file",
"exception": "{\"class\":\"Exception\",\"message\":\"File not found or not a file\",\"code\":0,\"file\":\"/var/www/html/custom_apps/context_chat/lib/Controller/QueueController.php:301\",\"trace\":\"#0 /var/www/html/custom_apps/context_chat/lib/Controller/QueueController.php(125): OCA\\ContextChat\\Controller\\QueueController->getFileSource(Object(OCA\\ContextChat\\Db\\QueueFile), Object(OC\\Files\\Node\\LazyRoot), Object(OCA\\ContextChat\\Service\\StorageService), Object(OC\\Files\\Config\\UserMountCache))\\n#1 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(165): OCA\\ContextChat\\Controller\\QueueController->getDocumentsQueueItems(Object(OCA\\ContextChat\\Service\\StorageService), Object(OC\\Files\\Node\\LazyRoot), Object(OCA\\ContextChat\\Db\\QueueMapper), Object(OCA\\ContextChat\\Db\\QueueContentItemMapper), Object(OC\\Files\\Config\\UserMountCache), 32)\\n#2 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(78): OC\\AppFramework\\Http\\Dispatcher->executeController(Object(OCA\\ContextChat\\Controller\\QueueController), 'getDocumentsQue...')\\n#3 /var/www/html/lib/private/AppFramework/App.php(137): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OCA\\ContextChat\\Controller\\QueueController), 'getDocumentsQue...')\\n#4 /var/www/html/lib/private/Route/Router.php(324): OC\\AppFramework\\App::main('OCA\\\\ContextChat...', 'getDocumentsQue...', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\\n#5 /var/www/html/ocs/v1.php(63): OC\\Route\\Router->match('/ocsapp/apps/co...')\\n#6 /var/www/html/ocs/v2.php(10): require_once('/var/www/html/o...')\\n#7 {main}\"}",
"CustomMessage": "File not found or not a file"
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/Controller/QueueController.php, especially getFileSource() and the /ocs/v2.php/apps/context_chat/queues/documents endpoint, then trace how getMountsForStorageId() selects a user for a storage. Reproduce the documented shared-mount ordering scenario and verify that initial indexing can process eligible files without File not found or not a file errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100