{"record":{"id":"ea972081a6c9ac9a","repo":"Kareadita/Kavita","slug":"smart-filter-doesnt-exist","errorCode":null,"errorMessage":"smart-filter-doesnt-exist","messagePattern":"smart-filter-doesnt-exist","errorType":"exception","errorClass":"OpdsException","httpStatus":null,"severity":"error","filePath":"Kavita.Services/OpdsService.cs","lineNumber":394,"sourceCode":"\n        return feed;\n    }\n\n    /// <summary>\n    /// Returns the Entities matching this smart filter.\n    /// </summary>\n    /// <param name=\"request\"></param>\n    /// <param name=\"ct\"></param>\n    /// <returns></returns>\n    /// <exception cref=\"ArgumentOutOfRangeException\"></exception>\n    public async Task<Feed> ResolveSmartFilter(OpdsItemsFromEntityIdRequest request, CancellationToken ct = default)\n    {\n        var userId = UnpackRequest(request, out var apiKey, out var prefix, out var baseUrl);\n\n        var filter = await unitOfWork.AppUserSmartFilterRepository.GetById(request.EntityId, ct);\n        if (filter == null)\n        {\n            throw new OpdsException(await localizationService.TranslateAsync(userId, \"smart-filter-doesnt-exist\"));\n        }\n\n        var feed = CreateFeed(await localizationService.TranslateAsync(userId, \"smartFilters-\" + filter.Id), $\"{apiKey}/smart-filters/{filter.Id}/\", apiKey, prefix);\n        SetFeedId(feed, \"smartFilters-\" + filter.Id);\n\n        var decodedFilter = SmartFilterHelper.Decode(filter.Filter);\n        var userParams = GetUserParams(request.PageNumber);\n\n\n        switch (decodedFilter.EntityType)\n        {\n            case FilterEntityType.Series:\n                var series = await unitOfWork.SeriesRepository.GetSeriesDtoForLibraryIdAsync(userId, userParams,\n                    (SeriesFilterV2Dto) decodedFilter, ct: ct);\n                var seriesMetadatas = await unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(series.Select(s => s.Id), ct);\n\n                foreach (var seriesDto in series)\n                {","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/OpdsService.cs#L376-L412","documentation":"Thrown by OpdsService.ResolveSmartFilter when a smart filter with the given EntityId cannot be found in the database (AppUserSmartFilterRepository.GetById returns null). This indicates the OPDS client requested a smart filter feed using an ID that does not correspond to any stored AppUserSmartFilter record. The error message is localized via the LocalizationService for the requesting user.","triggerScenarios":"An OPDS client sends a GET request to {apiKey}/smart-filters/{filterId}. The filterId in the URL maps to request.EntityId. The repository lookup returns null because the filter was deleted, the ID is wrong, or the filter belongs to a different user (if GetById is user-scoped).","commonSituations":"A user deleted a smart filter in the Kavita web UI but their OPDS reader app cached the old feed URL. The OPDS client is using a stale bookmark or cached link. The filterId was mistyped or corrupted in the URL. A different user's API key is being used to access another user's filter.","solutions":["Have the user refresh their smart filter list in the OPDS client to obtain current valid filter IDs.","Verify the filterId in the OPDS URL matches an existing smart filter in the user's Kavita dashboard.","If the filter was deleted, recreate it or remove the bookmark from the OPDS reader.","Ensure the correct user's API key is being used; smart filters are user-scoped.","Check Kavita's admin panel or database (AppUserSmartFilters table) to confirm which filter IDs exist."],"exampleFix":"// No code fix — this is a stale/deleted resource reference.\n// In the OPDS client, navigate back to the root feed and\n// re-select the smart filter to get a fresh URL.\n// If developing an OPDS client, validate the ID first:\n\n// GET /api/opds/{apiKey}/smart-filters/  -> list all valid filter IDs\n// then only use IDs returned in that list.","handlingStrategy":"validation","validationCode":"// Before requesting a smart filter feed, verify it exists:\n// var filter = await unitOfWork.AppUserSmartFilterRepository.GetById(filterId, ct);\n// if (filter == null)\n// {\n//     ShowUser(\"This smart filter no longer exists.\");\n//     return;\n// }\n// var feed = await opdsService.ResolveSmartFilter(request, ct);","typeGuard":null,"tryCatchPattern":"// try { var feed = await opdsService.ResolveSmartFilter(request, ct); }\n// catch (OpdsException ex)\n// {\n//     if (ex.Message.Contains(\"smart-filter-doesnt-exist\"))\n//     {\n//         // Refresh the smart-filter list; the cached ID is stale.\n//         await RefreshSmartFilterList();\n//         return BadRequest(\"Smart filter not found. Please refresh.\");\n//     }\n//     return BadRequest(ex.Message);\n// }","preventionTips":["In OPDS clients, always navigate from the live smart-filter feed rather than using cached URLs.","Refresh the OPDS feed after creating, editing, or deleting smart filters in the Kavita UI.","Use the correct user's API key; smart filters are user-scoped.","When building OPDS clients, handle 'smart-filter-doesnt-exist' by refreshing the filter list.","Avoid hardcoding smart filter IDs in bookmarks or scripts."],"tags":["opds","smart-filter","not-found","stale-reference","feed"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}