Show users from groups and contacts
"Error while loading contacts" (see nextcloud.log)

Searching in the contacts menu works and shows contacts.
Operating system: CentOS Linux release 7.4.1708 (Core)
Web server: nginx/1.13.12
Database: MariaDB-10.2.14
PHP version: php-fpm 7.2.5
Nextcloud version: 13.0.2
Where did you install Nextcloud from: Docker
Signing status: All checks passed.
Are you using external storage, if yes which one: no
Are you using encryption: no
Are you using an external user-backend, if yes which one: no
Browser: Firefox 59.0.2
Operating system: ArchLinux
Nextcloud log
TypeError: Argument 1 passed to OC\Group\Manager::getUserGroupIds() must implement interface OCP\IUser, null given, called in /nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php on line 160
/nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php - line 160: OC\Group\Manager->getUserGroupIds(NULL)
[internal function] OC\Contacts\ContactsMenu\ContactsStore->OC\Contacts\ContactsMenu\{closure}(*** sensitive parameters replaced ***)
/nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php - line 168: array_filter(Array, Object(Closure))
/nextcloud/lib/private/Contacts/ContactsMenu/ContactsStore.php - line 87: OC\Contacts\ContactsMenu\ContactsStore->filterContacts(Object(OC\User\User), Array, NULL)
/nextcloud/lib/private/Contacts/ContactsMenu/Manager.php - line 59: OC\Contacts\ContactsMenu\ContactsStore->getContacts(Object(OC\User\User), NULL)
/nextcloud/core/Controller/ContactsMenuController.php - line 61: OC\Contacts\ContactsMenu\Manager->getEntries(Object(OC\User\User), NULL)
[internal function] OC\Core\Controller\ContactsMenuController->index(NULL)
/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 161: call_user_func_array(Array, Array)
/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 91: OC\AppFramework\Http\Dispatcher->executeController(Object(OC\Core\Controller\ContactsMenuController), 'index')
/nextcloud/lib/private/AppFramework/App.php - line 115: OC\AppFramework\Http\Dispatcher->dispatch(Object(OC\Core\Controller\ContactsMenuController), 'index')
/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47: OC\AppFramework\App main('OC\\Core\\Control...', 'index', Object(OC\AppFramework\DependencyInjection\DIContainer), Array)
[internal function] OC\AppFramework\Routing\RouteActionHandler->__invoke(Array)
/nextcloud/li```b/private/Route/Router.php - line 297: call_user_func(Object(OC\AppFramework\Routing\RouteActionHandler), Array)
/nextcloud/lib/base.php - line 999: OC\Route\Router->match('/contactsmenu/c...')
/nextcloud/index.php - line 37: OC handleRequest()
{main}
Browser log
There was an error loading your contacts{
"readyState": 4,
"responseText": "HTML WITH HTTP 500 ERROR MESSAGE",
"status": 500,
"statusText": "Internal Server Error"
}
cc @georgehrke @ChristophWurst @danxuliu
There is a null check missing at https://github.com/nextcloud/server/blob/a00cb2c5d73e598d5800176fafa6209675126b7e/lib/private/Contacts/ContactsMenu/ContactsStore.php#L158. Basically the user manager is asked for a user of the given UID which seems to be invalid (for whatever reason) and therefore null is returned and passed into the group manager.
Can I help you with it? Do you need some more information?
@hoellen are you able to attach a debugger to your instance or add some logging statements to get the value of $entry->getProperty('UID')?
I used the following lines to get the value:
$tmp = $entry->getProperty('UID');
if ($this->userManager->get($tmp) == null) {
throw new \Exception("DEBUGGING: $tmp");
}
It returns "testuser124" . This is a testuser I had long time ago. He was deleted.
I looked up the value "testuser124" in my database and it occurs in the following tables:
I deleted the "testuser124" line in oc_accounts. But it doesn't changed anything.
As a workaround I added the following lines in the file ContactsStore.php. Since then the Contactsmenu works.
if ( $entry->getProperty('UID') == "testuser124") {
return false;
}
But: Where does the value come from?
Awesome findings, @hoellen. Thanks a lot!
But: Where does the value come from?
I assume it's coming from the system address, book. So that should be oc_cards, I assume. cc @rullzer @nickvergessen who might know a bit more about this. To me, this sounds like a bug.
Seems to be fixed with #10296
Yes, seems that's exactly the same issue. Hence, I'm closing this ticket.
Yep, this is the fix. Thanks!
Maybe there should be something in occ maintenance:repair to get the addressbook and usermanager in sync again?
Maybe there should be something in occ maintenance:repair to get the addressbook and usermanager in sync again?
Sounds sane. However, I'd rather try to track down why we have some dead UIDs in our database and make sure there are no leftovers in the first place.
I just want to let you know (maybe another has this issue too), that there is the command dav:sync-system-addressbook and after that the contacts menu appear even without the fix.
Furthermore the user "testuser124" is not anymore in the oc_cards table.