{"record":{"id":"75ebdddc65ff3554","repo":"Kareadita/Kavita","slug":"smart-filter-doesnt-exist-75ebdd","errorCode":"smart-filter-doesnt-exist","errorMessage":"smart-filter-doesnt-exist","messagePattern":"smart-filter-doesnt-exist","errorType":"exception","errorClass":"KavitaException","httpStatus":400,"severity":"warning","filePath":"Kavita.Services/StreamService.cs","lineNumber":53,"sourceCode":"\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\n        user.DashboardStreams.Add(createdStream);\n        unitOfWork.UserRepository.Update(user);\n        await unitOfWork.CommitAsync(ct);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/StreamService.cs#L35-L71","documentation":"Thrown by StreamService.CreateDashboardStreamFromSmartFilter when AppUserSmartFilterRepository.GetById(smartFilterId) returns null — the smart filter does not exist (or does not belong to the user). The message is translated to 'Smart Filter doesn't exist'. StreamController.AddDashboard does not catch it, so it surfaces via ExceptionMiddleware as HTTP 500 with that text.","triggerScenarios":"POST /api/stream/add-dashboard-stream?smartFilterId=N with a deleted, invalid, or other-user smart filter id.","commonSituations":"Stale smartFilterId cached in the UI after the filter was deleted; deep link/bookmark with an old id; cross-user id confusion.","solutions":["Use a smartFilterId from the user's current smart-filter list.","Refresh the smart filters in the UI before offering 'add to dashboard'.","If the filter was deleted, recreate it, then add the stream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const filters = await api.getSmartFilters();\nif (!filters.some(f => f.id === smartFilterId)) {\n  showError('Smart Filter not found');\n  return;\n}\nawait api.post(`/api/stream/add-dashboard-stream?smartFilterId=${smartFilterId}`);","typeGuard":"function isKnownFilterId(id: number, filters: { id: number }[]): boolean {\n  return filters.some(f => f.id === id);\n}","tryCatchPattern":null,"preventionTips":["Offer 'add to dashboard' only for filters in the user's current list.","Refresh smart filters after delete operations.","Drop stale smartFilterIds from deep links by validating before use."],"tags":["smart-filter","stream","dashboard","validation","not-found"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}