{"record":{"id":"fabbdb45932ad557","repo":"Kareadita/Kavita","slug":"could-not-grab-favicon-from-baseurl","errorCode":null,"errorMessage":"Could not grab favicon from {baseUrl}","messagePattern":"Could not grab favicon from (.+?)","errorType":"exception","errorClass":"KavitaException","httpStatus":null,"severity":"warning","filePath":"Kavita.Services/Metadata/CoverDbService.cs","lineNumber":153,"sourceCode":"                .Where(href => href.Split(\"?\")[0].EndsWith(\".png\", StringComparison.InvariantCultureIgnoreCase))\n                .ToList();\n\n            correctSizeLink = (pngLinks?.Find(pngLink => pngLink.Contains(\"32\")) ?? pngLinks?.FirstOrDefault());\n        }\n        catch (Exception ex)\n        {\n            _logger.LogError(ex, \"Error downloading favicon.png for {Domain}, will try fallback methods\", domain);\n        }\n\n        try\n        {\n            if (string.IsNullOrEmpty(correctSizeLink))\n            {\n                correctSizeLink = await FallbackToKavitaReaderFavicon(baseUrl);\n            }\n            if (string.IsNullOrEmpty(correctSizeLink))\n            {\n                throw new KavitaException($\"Could not grab favicon from {baseUrl}\");\n            }\n\n            var finalUrl = correctSizeLink;\n\n            // If starts with //, it's coming usually from an offsite cdn\n            if (correctSizeLink.StartsWith(\"//\"))\n            {\n                finalUrl = \"https:\" + correctSizeLink;\n            }\n            else if (!correctSizeLink.StartsWith(uri.Scheme))\n            {\n                finalUrl = Url.Combine(baseUrl, correctSizeLink);\n            }\n\n            _logger.LogTrace(\"Fetching favicon from {Url}\", finalUrl);\n            // Download the favicon.ico file using Flurl\n            var faviconStream = await FlurlConfiguration.CreateSafeRequest(finalUrl)\n                .AllowHttpStatus(\"2xx,304\")","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/Metadata/CoverDbService.cs#L135-L171","documentation":"Thrown at the end of DownloadFaviconAsync's fallback chain: after the HTML link-tag scrape failed or returned nothing AND FallbackToKavitaReaderFavicon(baseUrl) also returned empty, there is no favicon URL to download. The method explicitly raises KavitaException rather than returning empty so the caller knows the fetch truly failed (and so the negative cache marker is justified).","triggerScenarios":"A baseUrl whose HTML has no <link rel~'icon'>...href=.png> matching ValidIconRelations, and whose host is not in Kavita's remote fallback overrides list. correctSizeLink stays empty through both attempts, triggering the throw.","commonSituations":"Site uses only .ico (not .png) favicons and the parser only accepts .png; site blocks Kavita's user-agent; site is offline; host has no favicon at all; site is brand new and not in the curated override list.","solutions":["Verify the site actually exposes a favicon and is reachable from the Kavita host (curl the baseUrl).","If the site only ships .ico, that's unsupported by this parser — request the site add a .png or accept the missing icon.","Check network egress / proxy / DNS from the Kavita container to the external host.","As a caller, catch this and fall back to a default placeholder rather than surfacing the error to the user."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { favicon = await coverDbService.DownloadFaviconAsync(url, fmt, ct); }\ncatch (KavitaException ex) when (ex.Message.Contains(\"Could not grab favicon\"))\n{ favicon = null; // UI shows default favicon }","preventionTips":["Verify the external host is reachable and serves a .png favicon link tag.","Accept that some sites have no favicon — degrade to a placeholder.","Check network/DNS/proxy from the Kavita container to the remote host."],"tags":["favicon","metadata","network","fallback"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}