Fix registry search 500: handle non-JSON Harbor fixture response

Harbor fixture returns plain text, not JSON. The RegistrySearchEndpoints
deserialization crashed with an unhandled JsonException causing 500 on
every /api/v1/registries/images/search request. This blocked the release
creation wizard at Step 2 (Components).

Fix: catch JsonException and return empty results gracefully. The release
wizard now shows "no results" instead of silently failing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
master
2026-03-16 22:25:16 +02:00
parent 15e06db230
commit 757f5b3f0d

View File

@@ -109,6 +109,17 @@ public static class RegistrySearchEndpoints
RegistryId = "harbor-fixture"
});
}
catch (JsonException jex)
{
logger.LogWarning(jex, "Harbor returned non-JSON response for query '{Query}'", query);
return Results.Ok(new RegistrySearchResponse
{
Items = [],
TotalCount = 0,
RegistryId = "harbor-fixture"
});
}
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException or OperationCanceledException)
{
logger.LogWarning(ex, "Harbor registry unreachable during image search for query '{Query}'", query);