{"record":{"id":"a6ee25a00c73b65b","repo":"Kareadita/Kavita","slug":"no-user","errorCode":"no-user","errorMessage":"no-user","messagePattern":"no-user","errorType":"exception","errorClass":"KavitaException","httpStatus":400,"severity":"error","filePath":"Kavita.Services/StreamService.cs","lineNumber":50,"sourceCode":"    {\n        return await unitOfWork.UserRepository.GetDashboardStreams(userId, visibleOnly, ct);\n    }\n\n    public async Task<IEnumerable<SideNavStreamDto>> GetSidenavStreams(int userId, bool visibleOnly = true, CancellationToken ct = default)\n    {\n        return await unitOfWork.UserRepository.GetSideNavStreams(userId, visibleOnly, ct);\n    }\n\n    public async Task<IEnumerable<ExternalSourceDto>> GetExternalSources(int userId, CancellationToken ct = default)\n    {\n        return await unitOfWork.AppUserExternalSourceRepository.GetExternalSources(userId, ct);\n    }\n\n    public async Task<DashboardStreamDto> CreateDashboardStreamFromSmartFilter(int userId, int smartFilterId,\n        CancellationToken ct = default)\n    {\n        var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId, AppUserIncludes.DashboardStreams, ct);\n        if (user == null) throw new KavitaException(await localizationService.TranslateAsync(userId, \"no-user\"));\n\n        var smartFilter = await unitOfWork.AppUserSmartFilterRepository.GetById(smartFilterId, ct);\n        if (smartFilter == null) throw new KavitaException(await localizationService.TranslateAsync(userId, \"smart-filter-doesnt-exist\"));\n\n        var stream = user.DashboardStreams.FirstOrDefault(d => d.SmartFilter?.Id == smartFilterId);\n        if (stream != null) throw new KavitaException(await localizationService.TranslateAsync(userId, \"smart-filter-already-in-use\"));\n\n        var maxOrder = user!.DashboardStreams.Max(d => d.Order);\n        var createdStream = new AppUserDashboardStream()\n        {\n            Name = smartFilter.Name,\n            IsProvided = false,\n            StreamType = DashboardStreamType.SmartFilter,\n            Visible = true,\n            Order = maxOrder + 1,\n            SmartFilter = smartFilter\n        };\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/StreamService.cs#L32-L68","documentation":"Thrown by StreamService.CreateDashboardStreamFromSmartFilter when GetUserByIdAsync(userId, AppUserIncludes.DashboardStreams) returns null — the authenticated user's account cannot be loaded. The message is translated server-side before throwing ('User does not exist'). StreamController.AddDashboard does not catch KavitaException, so it reaches ExceptionMiddleware and returns HTTP 500 with that translated text.","triggerScenarios":"POST /api/stream/add-dashboard-stream?smartFilterId=N when the userId derived from the JWT no longer maps to a user (account deleted between login and the call, or an invalid/stale token).","commonSituations":"Admin deleted the user while their session was still active; token issued for a removed account; user table restored from a backup that lacks this user; race between auth and the repository read.","solutions":["Force a re-login / token refresh; if the account was deleted, the user must be recreated.","Verify the user still exists (admin: check Users list) before retrying.","On the client, treat a persistent 'no-user' as an auth failure and redirect to login."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.post(`/api/stream/add-dashboard-stream?smartFilterId=${id}`);\n} catch (e) {\n  // HTTP 500 translated 'User does not exist': session/account is invalid.\n  await auth.refreshOrLogout();\n}","preventionTips":["Handle 'no-user' as an auth failure: refresh the token or redirect to login.","Recreate the account if it was admin-deleted.","Do not retry the same call with the same invalid token."],"tags":["user","authentication","stream","dashboard","session"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}