From 19a1d5c62d5fb37f5212713361038b0dfaf636d4 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Tue, 2 Sep 2025 11:57:16 -0500 Subject: [PATCH] Fixed: Improve error handling for fingerprint search API failures --- .../MetadataSource/SkyHook/SkyHookProxy.cs | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 71da31e3e..1aaeaaba7 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -328,19 +328,36 @@ public List SearchForNewAlbum(string title, string artist) public List SearchForNewAlbumByRecordingIds(List recordingIds) { - var ids = recordingIds.Where(x => x.IsNotNullOrWhiteSpace()).Distinct(); - var httpRequest = _requestBuilder.GetRequestBuilder().Create() - .SetSegment("route", "search/fingerprint") - .Build(); + try + { + var ids = recordingIds.Where(x => x.IsNotNullOrWhiteSpace()).Distinct(); + var httpRequest = _requestBuilder.GetRequestBuilder().Create() + .SetSegment("route", "search/fingerprint") + .Build(); - httpRequest.SetContent(ids.ToJson()); - httpRequest.Headers.ContentType = "application/json"; + httpRequest.SetContent(ids.ToJson()); + httpRequest.Headers.ContentType = "application/json"; - var httpResponse = _httpClient.Post>(httpRequest); + var httpResponse = _httpClient.Post>(httpRequest); - return httpResponse.Resource.Select(MapSearchResult) - .Where(x => x != null) - .ToList(); + return httpResponse.Resource.Select(MapSearchResult) + .Where(x => x != null) + .ToList(); + } + catch (HttpException ex) + { + if (ex.Response != null && ex.Response.StatusCode == HttpStatusCode.ServiceUnavailable) + { + throw new SkyHookException("Search by fingerprint failed. LidarrAPI Temporarily Unavailable (503)"); + } + + throw new SkyHookException("Search by fingerprint failed. Unable to communicate with LidarrAPI. {0}", ex, ex.Message); + } + catch (Exception ex) when (ex is not SkyHookException) + { + _logger.Warn(ex, ex.Message); + throw new SkyHookException("Search by fingerprint failed. Invalid response received from LidarrAPI."); + } } public List SearchForNewEntity(string title)