Internal Server Error (must be of type string, null given at <<closure>>) publicly accessing any shared file or folder

When attempting to access a shared link, I get an internal server error. This happens for all links, all file types, and on folders. Does not happen if signed in to nextcloud.

Nextcloud version (eg, 20.0.5): 27.0.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.52
PHP version (eg, 7.4): 8.2.7

The issue you are facing:

When attempting to access a shared link, I get an Internal server error:


image

This line is present in my logs every time a link is visited:

Formatted:


0. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
   OC\AppFramework\Http\Dispatcher->dispatch()
1. /var/www/nextcloud/lib/private/Route/Router.php line 315
   OC\AppFramework\App::main()
2. /var/www/nextcloud/lib/base.php line 1064
   OC\Route\Router->match()
3. /var/www/nextcloud/index.php line 36
   OC::handleRequest()

Caused by:

TypeError: OCA\Files_Reader\Listeners\LoadViewerListener::__construct(): Argument #3 ($userId) must be of type string, null given at <<closure>>

 0. <<closure>>
    OCA\Files_Reader\Listeners\LoadViewerListener->__construct()
 1. /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php line 84
    ReflectionClass->newInstanceArgs()
 2. /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php line 124
    OC\AppFramework\Utility\SimpleContainer->buildClass()
 3. /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php line 142
    OC\AppFramework\Utility\SimpleContainer->resolve()
 4. /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php line 494
    OC\AppFramework\Utility\SimpleContainer->query()
 5. /var/www/nextcloud/lib/private/ServerContainer.php line 155
    OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback()
 6. /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php line 70
    OC\ServerContainer->query()
 7. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke()
 8. /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
 9. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
10. /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch()
11. /var/www/nextcloud/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php line 238
    OC\EventDispatcher\EventDispatcher->dispatchTyped()
12. /var/www/nextcloud/apps/files_sharing/lib/Controller/ShareController.php line 378
    OCA\Files_Sharing\DefaultPublicShareTemplateProvider->renderPage()
13. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 230
    OCA\Files_Sharing\Controller\ShareController->showShare()
14. /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController()
15. /var/www/nextcloud/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch()
16. /var/www/nextcloud/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main()
17. /var/www/nextcloud/lib/base.php line 1064
    OC\Route\Router->match()
18. /var/www/nextcloud/index.php line 36
    OC::handleRequest()

GET /index.php/s/c7FgSJdzcRnqF6g
from 192.168.0.170 at 2023-07-17T17:33:21+00:00

Raw: {"reqId":"W43aUgKJS98oPVktPC3I","level":3,"time":"2023-07-17T17:33:21+00:00","remoteAddr":"192.168.0.170","user":"--","app":"index","method":"GET","url":"/index.php/s/c7FgSJdzcRnqF6g","message":"OCA\\Files_Reader\\Listeners\\LoadViewerListener::__construct(): Argument #3 ($userId) must be of type string, null given in file '/var/www/nextcloud/apps/files_reader/lib/Listeners/LoadViewerListener.php' line 32","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36","version":"27.0.0.8","exception":{"Exception":"Exception","Message":"OCA\\Files_Reader\\Listeners\\LoadViewerListener::__construct(): Argument #3 ($userId) must be of type string, null given in file '/var/www/nextcloud/apps/files_reader/lib/Listeners/LoadViewerListener.php' line 32","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":183,"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":1064,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","Line":169,"Previous":{"Exception":"TypeError","Message":"OCA\\Files_Reader\\Listeners\\LoadViewerListener::__construct(): Argument #3 ($userId) must be of type string, null given","Code":0,"Trace":[{"function":"__construct","class":"OCA\\Files_Reader\\Listeners\\LoadViewerListener","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":84,"function":"newInstanceArgs","class":"ReflectionClass","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":124,"function":"buildClass","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php","line":142,"function":"resolve","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php","line":494,"function":"query","class":"OC\\AppFramework\\Utility\\SimpleContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/ServerContainer.php","line":155,"function":"queryNoFallback","class":"OC\\AppFramework\\DependencyInjection\\DIContainer","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php","line":70,"function":"query","class":"OC\\ServerContainer","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"__invoke","class":"OC\\EventDispatcher\\ServiceEventListener","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":87,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":99,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php","line":238,"function":"dispatchTyped","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/apps/files_sharing/lib/Controller/ShareController.php","line":378,"function":"renderPage","class":"OCA\\Files_Sharing\\DefaultPublicShareTemplateProvider","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"showShare","class":"OCA\\Files_Sharing\\Controller\\ShareController","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":183,"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":1064,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/apps/files_reader/lib/Listeners/LoadViewerListener.php","Line":32},"CustomMessage":"--"},"id":"64b57b61cb49b"}

Steps to reproduce:

  1. Share a file by clicking on share or details and share:

Share link is created.

  1. Open incognito window or sign out and visit the link
  2. Server error appears

Turn off your third-party Reader (ebook reader) app. Per your stack trace it is what is generate the error.

It doesn’t appear to have been updated to support any of the last couple of NC versions:

Thank you! I searched “Reader” and thought that might be it but nothing came up. I forgot about the ereader.

1 Like