diff --git a/lib/private/tagmanager.php b/lib/private/tagmanager.php
index 9bc461f25eb..1c7ace11469 100644
--- a/lib/private/tagmanager.php
+++ b/lib/private/tagmanager.php
@@ -65,6 +65,11 @@ class TagManager implements \OCP\ITagManager {
 	*/
 	public function load($type, $defaultTags = array(), $includeShared = false, $userId = null) {
 		if (is_null($userId)) {
+			$user = $this->userSession->getUser();
+			if ($user === null) {
+				// nothing we can do without a user
+				return null;
+			}
 			$userId = $this->userSession->getUser()->getUId();
 		}
 		return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
diff --git a/tests/lib/tags.php b/tests/lib/tags.php
index 547cd302d5d..a50855c88f3 100644
--- a/tests/lib/tags.php
+++ b/tests/lib/tags.php
@@ -62,6 +62,16 @@ class Test_Tags extends \Test\TestCase {
 		parent::tearDown();
 	}
 
+	public function testTagManagerWithoutUserReturnsNull() {
+		$this->userSession = $this->getMock('\OCP\IUserSession');
+		$this->userSession
+			->expects($this->any())
+			->method('getUser')
+			->will($this->returnValue(null));
+		$this->tagMgr = new OC\TagManager($this->tagMapper, $this->userSession);
+		$this->assertNull($this->tagMgr->load($this->objectType));
+	}
+
 	public function testInstantiateWithDefaults() {
 		$defaultTags = array('Friends', 'Family', 'Work', 'Other');