beeradmoore/dlss-swapper · error · Exception

Could not find any GOGCatalogProduct for url

Error message

Could not find any GOGCatalogProduct for url, {url}

What it means

After successfully deserializing the GOG catalog response, UpdateCacheImageAsync requires at least one product entry; an empty Products array throws this error. It means GOG's catalog recognized the URL but returned no matching product data, so no cache image can be resolved.

Solutions

  1. Verify PlatformId against the game's actual GOG product id
  2. Check the game page URL resolves on GOG (delisted games return empty products)
  3. Retry later if the game was recently added and not yet indexed
  4. Skip cache-image update gracefully when products are empty

Example fix

// before
if (catalogResponse.Products.Length == 0)
{
    throw new Exception($"Could not find any GOGCatalogProduct for url, {url}");
}
// after
if (catalogResponse.Products.Length == 0)
{
    return; // no image available; log and skip instead of throwing
}
Defensive patterns

Strategy: fallback

Validate before calling

// preflight: confirm the product exists before image update
using var probe = await httpClient.GetAsync(url);
var json = await probe.Content.ReadAsStringAsync();
if (string.IsNullOrWhiteSpace(json) || !json.Contains("products", StringComparison.OrdinalIgnoreCase))
    return; // skip, game not in catalog

Type guard

bool HasProducts(GOGCatalogResponse r) => r.Products.Length > 0;

Try / catch

try
{
    await gogGame.UpdateCacheImageAsync();
}
catch (Exception ex) when (ex.Message.Contains("Could not find any GOGCatalogProduct"))
{
    logger.LogInformation("No GOG product for {Url}; keeping existing cache image.", url);
}

Prevention

When it happens

Trigger: Calling UpdateCacheImageAsync for a game whose catalog lookup yields Products.Length == 0 — e.g. an incorrect PlatformId, a delisted/unreleased game, or querying the wrong regional catalog URL.

Common situations: Game removed from GOG storefront; typo or stale PlatformId after GOG restructured ids; game available in another region only; new game not yet indexed by the catalog endpoint.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of beeradmoore/dlss-swapper@ab9b1e2d4b (2026-09-15). Data as JSON: /api/errors/dfeba8309522f33c. Report an issue: GitHub.

Appendix: source

Thrown at src/Data/GOG/GOGGame.cs:83

        try
        {
            var url = "https://catalog.gog.com/v1/catalog?order=desc:score&productType=in:game&query=like:" + Uri.EscapeDataString(Title);
            var fileDownloader = new FileDownloader(url);
            using (var memoryStream = new MemoryStream())
            {
                await fileDownloader.DownloadFileToStreamAsync(memoryStream);
                memoryStream.Position = 0;

                var catalogResponse = JsonSerializer.Deserialize(memoryStream, SourceGenerationContext.Default.GOGCatalogResponse);
                if (catalogResponse is null)
                {
                    throw new Exception($"Could not deserialize GOGCatalogResponse for url, {url}");
                }

                if (catalogResponse.Products.Length == 0)
                {
                    throw new Exception($"Could not find any GOGCatalogProduct for url, {url}");
                }

                foreach (var product in catalogResponse.Products)
                {
                    if (product.Id.Equals(PlatformId, StringComparison.OrdinalIgnoreCase) == false)
                    {
                        continue;
                    }

                    if (string.IsNullOrWhiteSpace(product.CoverVertical) == false)
                    {
                        await DownloadCoverAsync(product.CoverVertical).ConfigureAwait(false);
                        return;
                    }
                }
            }
        }
        catch (Exception err)

View on GitHub (pinned to ab9b1e2d4b)