{"record":{"id":"563a905347284163","repo":"immich-app/immich","slug":"user-not-logged-in","errorCode":null,"errorMessage":"User not logged in","messagePattern":"User not logged in","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mobile/lib/providers/infrastructure/remote_album.provider.dart","lineNumber":83,"sourceCode":"  }\n\n  Future<List<RemoteAlbum>> sortAlbums(\n    List<RemoteAlbum> albums,\n    AlbumSortMode sortMode, {\n    bool isReverse = false,\n  }) async {\n    return await _remoteAlbumService.sortAlbums(albums, sortMode, isReverse: isReverse);\n  }\n\n  Future<RemoteAlbum?> createAlbum({\n    required String title,\n    String? description,\n    List<String> assetIds = const [],\n  }) async {\n    try {\n      final currentUser = ref.read(currentUserProvider);\n      if (currentUser == null) {\n        throw Exception('User not logged in');\n      }\n\n      final album = await _remoteAlbumService.createAlbum(\n        title: title,\n        owner: currentUser,\n        description: description,\n        assetIds: assetIds,\n      );\n\n      state = state.copyWith(albums: [...state.albums, album]);\n\n      return album;\n    } catch (error, stack) {\n      _logger.severe('Failed to create album', error, stack);\n      rethrow;\n    }\n  }\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/mobile/lib/providers/infrastructure/remote_album.provider.dart#L65-L101","documentation":"Thrown by the createAlbum provider in RemoteAlbumProvider before calling RemoteAlbumService.createAlbum. The service requires a User object as the album owner, so when ref.read(currentUserProvider) returns null (unauthenticated), the operation aborts with this exception. It means an album creation was attempted without a valid session.","triggerScenarios":"Calling createAlbum (title/description/assetIds) while currentUserProvider reads null — after logout/token expiry, or before login completes when the create action is triggered.","commonSituations":"User taps 'create album' after their session expired in the background; UI not disabled during logout transition; stale app state restored post-logout.","solutions":["Check currentUserProvider (or await auth state) before enabling/invoking album creation; disable the action when logged out.","Catch the exception, prompt the user to log in, then retry the creation.","Refresh the session token proactively so currentUserProvider doesn't yield null mid-session.","Route the create-album flow through authenticated screens only."],"exampleFix":"// before\nfinal currentUser = ref.read(currentUserProvider);\nif (currentUser == null) {\n  throw Exception('User not logged in');\n}\n// after\nfinal currentUser = ref.read(currentUserProvider);\nif (currentUser == null) {\n  await ref.read(authProvider.notifier).reauthenticate();\n  throw const UnauthenticatedException(); // handled upstream with a login prompt\n}","handlingStrategy":"validation","validationCode":"final user = ref.read(currentUserProvider);\nif (user == null) {\n  // disable create action / prompt login first\n  return;\n}","typeGuard":"bool hasUser(User? u) => u != null && u.id.isNotEmpty;","tryCatchPattern":"try {\n  await ref.read(remoteAlbumProvider.notifier).createAlbum(title: title);\n} catch (e) {\n  if (e.toString().contains('User not logged in')) {\n    await promptLogin();\n  } else {\n    rethrow;\n  }\n}","preventionTips":["Disable album-creation UI when currentUserProvider is null","Re-authenticate before long user flows","Refresh session tokens proactively","Persist in-flight actions to retry after re-login"],"tags":["authentication","flutter","riverpod","albums"],"backgroundTag":"authentication-required","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}