{"record":{"id":"c5e45b432c4e7c12","repo":"Kareadita/Kavita","slug":"could-not-grab-favicon-from-baseurl-sanitize","errorCode":null,"errorMessage":"Could not grab favicon from {baseUrl.Sanitize()}","messagePattern":"Could not grab favicon from (.+?)","errorType":"exception","errorClass":"KavitaException","httpStatus":null,"severity":"info","filePath":"Kavita.Services/Metadata/CoverDbService.cs","lineNumber":402,"sourceCode":"\n        // Cache immediately\n        await CacheDataAsync(urlsFileName, allOverrides);\n\n\n        if (string.IsNullOrEmpty(allOverrides)) return correctSizeLink;\n\n        var cleanedBaseUrl = baseUrl.Replace(\"https://\", string.Empty);\n        var externalFile = allOverrides\n            .Split(\"\\n\")\n            .Select(url => url.Trim('\\n', '\\r')) // Ensure windows line terminators don't mess anything up\n            .FirstOrDefault(url =>\n                cleanedBaseUrl.Equals(url.Replace(\".png\", string.Empty)) ||\n                cleanedBaseUrl.Replace(\"www.\", string.Empty).Equals(url.Replace(\".png\", string.Empty)\n                ));\n\n        if (string.IsNullOrEmpty(externalFile))\n        {\n            throw new KavitaException($\"Could not grab favicon from {baseUrl.Sanitize()}\");\n        }\n\n        return $\"{NewHost}favicons/{externalFile}\";\n    }\n\n    private async Task<string> FallbackToKavitaReaderPublisher(string publisherName)\n    {\n        const string publisherFileName = \"publishers.txt\";\n        var allOverrides = await GetCachedData(publisherFileName) ??\n                           await $\"{NewHost}publishers/{publisherFileName}\".GetStringAsync();\n\n        // Cache immediately\n        await CacheDataAsync(publisherFileName, allOverrides);\n\n        if (string.IsNullOrEmpty(allOverrides)) return string.Empty;\n\n        var externalFile = allOverrides\n            .Split(\"\\n\")","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/Metadata/CoverDbService.cs#L384-L420","documentation":"Thrown inside FallbackToKavitaReaderFavicon (the curated favicon-override lookup): after loading allOverrides from favicons.txt, no line matches cleanedBaseUrl (with or without leading 'www.' and after stripping '.png'). The throw propagates up to DownloadFaviconAsync where it becomes the overall 'no favicon' failure.","triggerScenarios":"A baseUrl that is not present in the curated favicons.txt override list, reached only when the on-page scrape already failed. cleanedBaseUrl (https:// stripped, no .png) must match a line exactly or after removing 'www.'.","commonSituations":"Niche/external site not in the override list; site URL has a subdomain (the matcher only strips 'www.', not arbitrary subdomains); override list is stale or failed to download so it's empty; trailing slash or port in the URL prevents exact match.","solutions":["Confirm the favicons.txt override file was downloaded/parsed (check NewHost reachability and cache).","Normalize the baseUrl before lookup — strip trailing slash and ports if the override list expects bare hosts.","If the site isn't curated, accept fallback failure; contribute the site to the override list if you control it.","As a caller, catch KavitaException and degrade to a default favicon."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"var externalFile = allOverrides.Split(\"\\n\").Select(l => l.Trim('\\n','\\r')).FirstOrDefault(url =>\n    cleanedBaseUrl.Equals(url.Replace(\".png\", string.Empty)) ||\n    cleanedBaseUrl.Replace(\"www.\", string.Empty).Equals(url.Replace(\".png\", string.Empty)));\nif (string.IsNullOrEmpty(externalFile)) return string.Empty;","typeGuard":null,"tryCatchPattern":"try { link = await FallbackToKavitaReaderFavicon(baseUrl); }\ncatch (KavitaException ex) when (ex.Message.Contains(\"Could not grab favicon\"))\n{ link = string.Empty; }","preventionTips":["Confirm the favicons.txt override file downloaded and is non-empty.","Normalize baseUrl (strip ports/trailing slash) before matching.","Contribute missing sites to the override list if curated."],"tags":["favicon","metadata","override-list","fallback"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}